home *** CD-ROM | disk | FTP | other *** search
/ Computer Inter@ctive 17 / Computer Interactive cdrom 17 - gen 99.iso / ZDNETIT / CONTENT / OPTIVDOS.ZIP / DOC.ZIP / HANDBOOK.TXT < prev    next >
Encoding:
Text File  |  1998-10-21  |  97.5 KB  |  2,027 lines

  1.        OOOOOO                            VV        VV
  2.       OO    OO   PPPPPPP   TTTTTTTT  II   VV      VV  EEEEEE   CCCCCC
  3.       OO    OO   PP    PP     TT     II    VV    VV   EE       CC
  4.       OO    OO   PPPPPPP      TT     II     VV   VV   EEEEEE   CC
  5.       OO    OO   PP           TT     II       VVV     EE       CC
  6.        OOOOOO    PP           TT     II        V      EEEEEE   CCCCCC
  7.  
  8.  
  9.                        OptiVec  Version 1.2
  10.                          for Borland C++
  11.                      (Version 3.0 or higher)
  12.  
  13.  
  14.                       Dr. Martin Sander Software Development
  15.                       Serturnerstr. 11
  16.                       D-37085 Goettingen
  17.                       Germany
  18.                       e-mail: MartinSander@Bigfoot.com
  19.                       http://www.optivec.com
  20.  
  21.  
  22. For the commercial version, please order by e-mail or through our web-site!
  23. See chapter 1.3 for details.
  24.  
  25.  
  26. *****************************************************************************
  27.  
  28. F i r s t  P a r t :   File  HANDBOOK.TXT
  29.  
  30. !!     This is an ASCII text file!  It is best viewed with a simple        !!
  31. !!     DOS editor.                                                         !!
  32. !!     If you load this file into a word processor under Windows, you      !!
  33. !!     must use the filter "DOS text".                                     !!
  34. !!     Alternatively, you may use FCONVERT (shipped with Borland C++) to   !!
  35. !!     convert from ASCII (OEM) into the ANSI character set.               !!
  36. !!     preferably use the lettertype CourierNew 10 pt.                     !!
  37.  
  38. OptiCode (TM) and OptiVec (TM) are trademarks of Dr. Martin Sander
  39. Software Dev.  Other brand and product names mentioned in this handbook
  40. for identification purposes are trademarks or registered trademarks of
  41. their respective holders.
  42.  
  43.                  **************************************
  44.    German-speaking users:
  45.        Um die Kosten für das Herunterladen der Shareware-Version
  46.        über das Internet für alle so gering wie möglich zu halten,
  47.        enthält diese nur die englische Dokumentation. Sie finden
  48.        die deutsche Beschreibung separat unter
  49.              http://www.gwdg.de/~msander/Download/BC/OVDOCD.ZIP
  50.                  **************************************
  51.  
  52.  
  53. ****************************************************************************
  54. *                                                                          *
  55. *******                           Contents                           *******
  56. *                                                                          *
  57. ****************************************************************************
  58.  
  59. F i r s t  P a r t :   File  HANDBOOK.TXT
  60.  
  61. This HANDBOOK describes the main part of the OptiVec package, which
  62. is VectorLib. The other parts, CMATH and MatrixLib, have their own
  63. descriptions in separate files.
  64. MatrixLib: see Matrix.TXT
  65. CMATH:     see CMATH.TXT.
  66.  
  67. 1. Introduction
  68.     1.1 What is VectorLib and Why are the VectorLib Functions so Fast?
  69.     1.2 Licence Terms
  70.     1.3 Registered Version
  71.     1.4 Getting Started
  72.  
  73. 2. The Elements of VectorLib Routines
  74.     2.1 The Data Types ui,  quad,  and extended
  75.     2.2 Complex Numbers: The Data Types fComplex,  dComplex,  eComplex
  76.     2.3 Vectors and Arrays: The Data Types fVector, dVector, eVector,
  77.         cfVector,  cdVector,  ceVector,   siVector, iVector, liVector,
  78.         usVector,  uVector,  ulVector,  qiVector,  and  uiVector
  79.     2.4 Real-number Functions: The Prefixes VF_,  VD_,  and VE_
  80.     2.5 Complex-number Functions: The Prefixes VCF_, VCD_, and VCE_
  81.     2.6 Functions of the Integer Data Types: The Prefixes VI_, VSI_,
  82.         VLI_, VQI_, VU_, VUS_, VUL_, and VUI_
  83.     2.7 Common Functions of Several Data Types: The Prefix V_
  84.  
  85. 3. The Environment
  86.     3.1 The Different Library Versions: Selecting Language, Memory Model,
  87.         and Processor
  88.  
  89. 4. VectorLib Functions and Routines: A Short Overview
  90.     4.1 Generation, Initialization and De-Allocation of Vectors
  91.     4.2 Index-oriented Manipulations
  92.     4.3 Data-Type Interconversions
  93.     4.4 More about Integer Arithmetics
  94.     4.5 Basic Functions of Complex Vectors
  95.     4.6 Mathematical Functions
  96.         4.6.1 Rounding
  97.         4.6.2 Comparisons
  98.         4.6.3 Direct Bit-Manipulation
  99.         4.6.4 Basic Arithmetics
  100.         4.6.5 Powers
  101.         4.6.6 Exponentials and Hyperbolic Functions
  102.         4.6.7 Logarithms
  103.         4.6.8 Trigonometric Functions
  104.     4.7 Analysis
  105.     4.8 Signal Processing:Fourier Transforms and Related Topics
  106.     4.9 Statistical Functions and Building Blocks
  107.     4.10 Input and Output
  108.     4.11 Graphics
  109.  
  110. 5. Error Handling
  111.     5.1 General Remarks
  112.     5.2 Integer Errors
  113.     5.3 Floating-Point Errors
  114.         5.3.1 Differences between Borland C++ 4.0 and earlier versions
  115.     5.4 The Treatment of Denormal Numbers
  116.     5.5 Advanced Error Handling: Writing Messages into a File
  117.  
  118. 6. Trouble-Shooting
  119.     6.1 General Problems
  120.     6.2 Problems with Windows 3.x?
  121.     6.3 Problems with the 16-bit Linker?
  122.  
  123. 7. The include-files of VectorLib
  124.  
  125.  
  126. S e c o n d  P a r t :  File  FUNCREF.TXT
  127.  
  128.  8.  Alphabetical Reference
  129.  
  130.  9.  Non-vectorized Functions
  131.  
  132. 10. VectorLib Error Messages
  133.  
  134.  
  135.  
  136. ****************************************************************************
  137. *                                                                          *
  138. *******                       1. Introduction                        *******
  139. *                                                                          *
  140. ****************************************************************************
  141.  
  142.  
  143. 1.1 What is VectorLib and Why are the VectorLib Functions so Fast?
  144. ------------------------------------------------------------------
  145.  
  146. VectorLib offers a powerful library of routines for numerically demanding
  147. applications, making the philosophy of vectorized programming available for
  148. C/C++, Pascal, and Fortran languages. VectorLib serves to overcome the
  149. limitations of loop management of conventional compilers - which proved to
  150. be one of the largest obstacles in the programmer's way towards efficient
  151. coding for scientific and data analysis applications.
  152.  
  153. Conventionally, a vector, i.e. a one-dimensional array of data of the same
  154. type, would be processed by "dissolving" it into a loop over its elements,
  155. leaving it to the compiler to produce efficient code. Compiled code, however,
  156. is always far from perfect. This means that your computer is occupied with
  157. slow and often inaccurate calculations. Now, with VectorLib, things become
  158. easier: vectors are processed as a whole; they need no longer be dissolved
  159. into loops. A large set of strictly typed functions is defined and realized
  160. in a tight Assembler-written implementation.
  161.  
  162. In comparison to the old vector language APL, VectorLib has the advantage of
  163. being incorporated into the modern and versatile languages C/C++, Pascal, and
  164. Fortran. Recent versions of C++ and Fortran do already offer some sort of
  165. vector processing, by virtue of iterator classes using templates (C++) and
  166. field functions (Fortran90). Both of these, however, are basically a con-
  167. venient means of letting the compiler write the loop for you and then compile
  168. it to the usual inefficient code. The same is true for the popular BLAS
  169. (Basic Linear Array Subroutine) libraries for Fortran. In comparison to
  170. these approaches, VectorLib is superior mainly with respect to execution
  171. speed - on the average by a factor of 2-3, in some cases even up to 8.
  172. The performance is no longer limited by the quality of your compiler, but
  173. rather by the real speed of the processor!
  174.  
  175. Moreover, the input and output vectors of VectorLib routines may be of
  176. variable size and it is possible to process only a part (e.g., the first 100
  177. elements, or every 10th element) of a vector, which is another important
  178. advantage of the VectorLib functions over other approaches, where only whole
  179. arrays are processed.
  180.  
  181. Using VectorLib routines instead of loops can make your source code much more
  182. compact and far better readable.
  183.  
  184. Besides this increased efficiency and ease of programming, the wide range of
  185. routines and functions covered by VectorLib makes this package the preferrable
  186. programming tool for scientific and data analysis applications, competing with
  187. many high-priced integrated systems, but imbedded into your favourite
  188. programming language:
  189.  
  190. *   All operators and mathematical functions of C/C++ are implemented in
  191.     vectorized form; additionally many more mathematical functions are
  192.     included which normally would have to be calculated by more or less
  193.     complicated combinations of existing functions. Not only the execution
  194.     speed, but also the accuracy of the results is greatly improved.
  195.  
  196. *   Building blocks for statistical data analysis are supplied.
  197.  
  198. *   Derivatives, integrals, interpolation schemes are included.
  199.  
  200. *   Fast Fourier Transform techniques allow for efficient convolutions,
  201.     correlation analyses, spectral filtering, and so on.
  202.  
  203. *   Graphical representation of data offers a convenient way of monitoring
  204.     the results of vectorized calculations.
  205.  
  206. *   Each function exists for every data type for which this is reasonable.
  207.     The data type is signalled by the prefix of the function name. No
  208.     implicit name mangling or other specific C++ features are used, which
  209.     makes VectorLib usable in C as well as in specific C++ programs.
  210.     Moreover, the names and the syntax of nearly all functions are the same
  211.     in C/C++, Pascal and Fortran languages.
  212.  
  213. *   Besides the vectorized complex functions, CMATH is included. This is a
  214.     library of complex operations and functions designed to be a faster,
  215.     safer and more complete replacement to the complex class libraries
  216.     shipped with C++ compilers. Moreover, CMATH does not require C++, but
  217.     may be used with simple C.
  218.  
  219. *   A large set of matrix operations is provided by MatrixLib, included
  220.     in the OptiVec package.
  221.  
  222.  
  223. As noted above, all functions, except some of the graphics and I/O routines,
  224. are written in Assembly language. This made optimizations possible which are
  225. not available in code produced by a compiler. You need not know any of the
  226. technical details described in the following lines and you may skip them,
  227. but perhaps these explanations will give you an idea of which performance
  228. to expect from VectorLib.
  229.  
  230. *   Floating-point constants, which are needed in the evaluation of
  231.     mathematical functions, are left on the floating-point number stack as
  232.     long as they are needed. This saves a large amount of loading/unloading
  233.     operations which are necessary if a mathematical function is called for
  234.     each element of a vector separately.
  235.  
  236. *   Where necessary, all eight coprocessor registers are employed. (For
  237.     present compilers, it is already an excellent achievement to master the
  238.     book-keeping for only four coprocessor registers.)
  239.  
  240. *   The addressing of vector elements is still a major source of inefficiency
  241.     with present compilers. Swtiching forth and back between input and output
  242.     vectors, a large number of redundant addressing operations is performed.
  243.     The strict (and easy!) definitions of all VectorLib functions allow to
  244.     reduce these operations to a minimum.
  245.  
  246. *   The 32-bit operations of the 386+ and the improved coprocessor commands
  247.     of the 387+ are consequently used. (This is why the present Shareware
  248.     version does not run on 286 machines and not without coprocessor.)
  249.  
  250. *  For any operations with floating-point numbers that can also be performed
  251.    using integer commands (like copying, swapping, or pushing onto the stack),
  252.    the faster method is consistently employed.
  253.  
  254. *  C compilers convert a float into a double, before passing it to a mathe-
  255.    matical function. This approach was useful at times when disk memory was
  256.    too great a problem to include separate functions for each data type in
  257.    the .LIB files stored on disk, but it is simply inefficient on modern PCs.
  258.    Consequently, no such implicit conversions are present in the VectorLib
  259.    routines. Here, a function of a float is calculated to float (i.e. single)
  260.    precision, wasting no time for the calculation of more digits which would
  261.    be discarded anyway.
  262.  
  263. *  All external function calls are eliminated from the inner loops of the
  264.    vector processing. This saves the execution time necessary for the
  265.    "call / ret" pairs and for loading the parameters on the stack.
  266.  
  267. *  To ensure proper parallel processing of the CPU and the floating-point
  268.    unit, compilers have to be careful with the synchronization, adding a
  269.    lot of "wait" statements to the program code. Within the tightly defined
  270.    VectorLib routines, wait commands are used only where it is really
  271.    necessary (not relevant for the Pentium processor: no "wait" needed
  272.    at all).
  273.  
  274. *  In many cases (like, e.g., the fast integer addition in VI_addC), the
  275.    vectors are processed in chunks of up to four elements instead of single
  276.    ones, reducing the relative amount of time spent for loop management.
  277.  
  278. *  In addition to these vector-specific optimizations, VectorLib employs all
  279.    optimizations you expect from good compilers, including  organization of
  280.    the code for most efficient use with superscalar processors like the
  281.    Pentium and its competitors.
  282.  
  283.  
  284. The implementation described in this documentation refers to Borland C++,
  285. version 3.0 or later for DOS and Microsoft Windows 3.0 or later (or Win-OS
  286. sessions under IBM OS/2 2.0 or later; in the following, we will simply speak
  287. of "Windows"). The library for the memory model FLAT for Windows95 and
  288. WindowsNT requires Borland C++, version 4.0 or higher.
  289.  
  290. Depending on your choice when ordering or downloading the Shareware version,
  291. you have got either of the following three library versions:
  292. memory model FLAT for Windows95/NT,
  293.              LARGE for DOS, or
  294.              LARGE for Windows 3.x.
  295. All of them require, at least, a 386 computer equipped with a 387
  296. coprocessor. This means: no emulation, no 486SX, but preferably 486DX,
  297. Pentium or higher.
  298. The full (registered) version contains libraries for all memory models of
  299. DOS, 16-bit Windows and 32-bit Windows. These libraries in turn are shipped
  300. in three versions:
  301. one for 486DX and Pentium computers, the second for 386 with 387,
  302. the third for 286 with or without coprocessor, i.e. with emulation.
  303.  
  304. Versions for other C compilers and for Pascal, Delphi, and Fortran are in
  305. preparation.
  306. For two-dimensional arrays, a beta release of MatrixLib comes with VectorLib,
  307. offering optimized operations like matrix arithmetics, algebra,
  308. decompositions, etc.
  309. TensorLib is planned as a future extension of these concepts for general
  310. multidimensional arrays.
  311.  
  312.  
  313. 1.2 Licence Terms
  314. -----------------
  315.  
  316. This is the English Shareware version of OptiVec for Borland C++
  317. ("SOFTWARE"). It may be used under the following licence terms:
  318.  
  319. 1. You may test the SOFTWARE free of charge for an unlimited period of time.
  320.    This testing phase ends when you permanently integrate functions of this
  321.    SOFTWARE into any of your applications (programs, program parts...).
  322. 2. If you want to use this SOFTWARE for commercial purposes, you have
  323.    to purchase the registered version (see chapter 1.3).
  324. 3. Use of this SOFTWARE for educational purposes at schools and universities
  325.    remains free of charge. However, if any application created under these
  326.    terms is sold to others or otherwise used for commercial purposes,
  327.    paragraph 2 applies.
  328. 4. Distributing this SOFTWARE to others is allowed only in one of the
  329.    following two ways:
  330.    a) linked into your programs, so that the parts stemming from this
  331.       SOFTWARE do no longer appear as a library.
  332.    b) as a whole in unchanged form (in particular the Copyright and Licence
  333.       statements!), whereby you may ask a fee only and exclusively for the
  334.       physical act of copying the SOFTWARE.
  335. 5. This SOFTWARE is provided on an "as is" basis. Any explicit or implicit
  336.    warranties for the SOFTWARE are excluded.
  337.    Despite thorough testing of the SOFTWARE, errors and bugs cannot
  338.    be excluded with certainty. No claims as to merchantability or fitness
  339.    for a particular purpose are made.
  340.    You may not use the SOFTWARE in any environment or situation where
  341.    personal injury or excessive damage to anyone's property (including
  342.    your own) could arise from malfunctioning of the SOFTWARE.
  343.  
  344.  
  345. Copyright for the SOFTWARE and its documentation (C) 1996-1998 Martin Sander
  346.  
  347. All rights reserved, including those of translation into foreign languages.
  348.  
  349. Address of the author:
  350.               Dr. Martin Sander Software Development
  351.               Sertürnerstr. 11
  352.               D-37085 Göttingen
  353.               Germany
  354.               e-mail: MartinSander@Bigfoot.com
  355.  
  356.  
  357.  
  358. 1.3 Registered Version
  359. ----------------------
  360.  
  361. The full (registered) version of OptiVec
  362.  
  363. -  supports all memory models of Windows95, NT, 3.x, and DOS
  364.  
  365. -  has individually optimized libraries for each degree of processor
  366.    backward-compatibility:
  367.       486DX/Pentium+
  368.       386+ (387 coprocessor required)
  369.       286+ (no coprocessor required).
  370.  
  371. -  comes with printed documentation.
  372.  
  373. -  can be ordered at the following conditions:
  374.  
  375.    a) if you can pay in German Marks (from 1999 on: in Euro)
  376.       and order directly from the author, the price is
  377.       DM  399,- for  1 unit,
  378.       DM 1399,- for  5 units,
  379.       DM 2299,- for 10 units    (incl. 16% VAT, plus DM 10,- handling charge).
  380.       Please order by sending an e-mail to MartinSander@bigfoot.com
  381.       or use a print-out of the file ORDER.TXT.
  382.       Payment options:
  383.           - pre-paid by DM Eurocheque
  384.           - C.O.D. (Cash-On-Delivery)
  385.           - upon invoice (only within Germany, net 14 days)
  386.  
  387.       If you have a European VAT ID, or if you order from outside the
  388.       European Union, you are exempt from the German VAT, but you may
  389.       have to pay your local VAT and/or import duties according to
  390.       local laws.
  391.  
  392.    b) International credit card or USD cheque payment is possible by
  393.       ordering through ours or the following web-sites:
  394.  
  395.       http://www.atlantic-coast.com/cgi-bin/sellonline/136.htm
  396.       $ 250 for  1 unit,
  397.       $ 800 for  5 units,
  398.       $1500 for 10 units
  399.       Add $5 for S&H and applicable VAT.
  400.  
  401.       http://www.shareit.com/programs/101557.htm         (English handbook)
  402.       http://www.shareit.com/deutsch/programs/101556.htm (German handbook)
  403.       $ 255 for  1 unit (including S&H). Add applicable VAT.
  404.  
  405.       USD prices are subject to change without notice, especially in the case
  406.       of strong exchange-rate fluctuations. Please see the actual prices
  407.       at the web-site mentioned.
  408.  
  409. Purchasing the full (registered) version gives you the right to use it on
  410. as many computers at a time as the number of units you bought.
  411. Corporate site and world-wide licences are available upon request.
  412.  
  413.  
  414. 1.4 Getting Started
  415. -------------------
  416.  
  417. To install OptiVec, please follow these steps:
  418.  
  419. 1.  In order to use OptiVec, you need an already installed copy of Borland
  420.     C/C++. Install OptiVec by executing INSTALL.EXE from the root directory
  421.     of the installation disk or CD-ROM. Normally, OptiVec will be installed
  422.     into a sub-directory of Borland C/C++, named "OPTIVEC".
  423.  
  424. 2.  Assuming your Borland C directory is C:\BC,  add
  425.        C:\BC\OPTIVEC\LIB       to the library search path  and
  426.        C:\BC\OPTIVEC\INCLUDE   to the include-file search path of the IDE
  427.                                (and of the configuration file TURBOC.CFG, in
  428.                                case you are using the command-line compiler).
  429.  
  430. 3.  Choose the desired platform (DOS, Windows3.x, or Win32).
  431.     If you chose DOS or Windows3.x, select the memory model LARGE.
  432.     (For Win32, it is automatically FLAT).
  433.     You should also choose 386 code generation and real coprocessor
  434.     commands (i.e., no emulation).
  435.  
  436. 4.  Add the desired OptiVec libraries to your project list.
  437.     For DOS programs, these are
  438.         VCL3.LIB,  MCL3.LIB, and CMATHL3.LIB.
  439.     For Windows3.x, you need
  440.         VCL3W.LIB, MCL3W.LIB, and CMATHL3W.LIB.
  441.     Of course, if you do not use MatrixLib or CMATH, you do not need
  442.     to include their libraries.
  443.     For Win32 (Windows 95, NT), please choose
  444.         VCF3W.LIB.
  445.         (For the 32-bit model, CMATH and MatrixLib are integrated
  446.          into the library VCF3W.LIB.)
  447.  
  448. 5.  Use #include directives to declare VectorLib and CMATH functions by
  449.     including the header files described in chapter 7.
  450.     To get everything at once, declare
  451.         #include <VecAll.h>
  452.         #include <MatAll.h>.
  453.     If you are writing ObjectWindows applications, any OptiVec header
  454.     files should be included after the OWL header files.
  455.  
  456. 6. 16-bit programs only:
  457.     *   If the linker option "process extended dictionaries" is available
  458.         in your version of Borland C++, you must switch it on.
  459.         Otherwise, you might get a "Table limit exceeded" linker error.
  460.  
  461.     *   OptiVec works with Borland (Turbo) C++, version 3.0 or higher.
  462.         Since, from version 4.0 on, Borland changed the name of the error
  463.         handling routine matherr (without underbar) into _matherr (with a
  464.         leading underbar), any 16-bit program using CMATH has to call a macro,
  465.         NEWMATHERR, which takes  care of redirecting calls to _matherr,
  466.         if necessary. You should place the call to NEWMATHERR into the
  467.         module containing  main() or OwlMain():
  468.  
  469.              #include .....
  470.              #include <VecAll.h>
  471.              NEWMATHERR
  472.  
  473.              int main( void )
  474.              {    ..........   }
  475.  
  476.         If you forget to call NEWMATHERR, you will get a linker error
  477.         "Unresolved external _matherr" in the Borland C versions from 4.0 on.
  478.  
  479.         Inclusion of the macro NEWMATHERR is not needed for 32-bit programs.
  480.  
  481. After these preparations, all OptiVec functions are available for your
  482. programs.
  483.  
  484. Should you wish to remove OptiVec from your computer after testing, please
  485. simply delete the directory OPTIVEC with its subdirectories. The installation
  486. of OptiVec does not affect any files outside its own directory, so there
  487. is nothing else to get rid of.
  488.  
  489.  
  490.  
  491. ****************************************************************************
  492. *                                                                          *
  493. *******               2. Elements of VectorLib Routines              *******
  494. *                                                                          *
  495. ****************************************************************************
  496.  
  497. 2.1 The Data Types ui,  quad,  and extended
  498. -------------------------------------------
  499.  
  500. To increase the versatility and completeness of VectorLib, three additional
  501. data types are defined in <VecLib.h>:
  502.  
  503. The data type ui (short for "unsigned index") is used for the indexing of
  504. vectors and is defined as "unsigned int". However, in the HUGE model (sup-
  505. ported only in the registered version of VectorLib), ui is defined as
  506. "unsigned long", in order to correctly address huge arrays (greater than
  507. 64 kBytes!).
  508.  
  509. Starting already with the 8086/8087 processor pair, the Intel processors
  510. are able to process integer numbers of up to 64 bits (8 bytes). We call the
  511. 64-bit type "quad" (for "quadword integer"). It is not fully supported by
  512. Borland C++. Therefore, floating-point numbers (preferably long doubles
  513. with their 64-bit mantissa) have to be used as intermediates. The necessary
  514. interface functions, setquad, quadtod and _quadtold, are described in
  515. chapter 9.
  516. The type quad is always signed. There is not anything like an "unsigned quad".
  517.  
  518. The data type extended, which is familiar to Turbo Pascal users, is defined
  519. as a synonym for "long double". The reason behind this is that all VectorLib
  520. routines shall have identical names in C/C++, Pascal and Fortran languages.
  521. Since the function prefixes are derived from the data types of the processed
  522. vectors (see below), this necessitates the definition of alias names for some
  523. data types denoted differently in the various languages. While the letter
  524. "L" (which could possibly stand for "long double") is already overcrowded by
  525. the data types long int and unsigned long, the letter "E" is unique to the
  526. data type extended and therefore used in the prefixes for vectors and
  527. functions of long double precision. This way, the letters defining the real-
  528. number data types are in alphabetical proximity: "D" for double, "E" for
  529. extended, and "F" for float. Maybe the future will bring high-precision
  530. 128-bit and 256-bit real numbers which could find their place in this series
  531. as "G" for "great" and "H" for "hyper".
  532.  
  533.  
  534.  
  535. 2.2 Complex Numbers:
  536. The Data Types fComplex,  dComplex,  eComplex
  537. ---------------------------------------------
  538.  
  539. Complex numbers are treated in C/C++ in quite a confusing way. ANSI C offers
  540. only a struct complex, Borland's C/C++ compiler additionally a struct
  541. _complexl for complex numbers of double and long double precision, resp.
  542. The real and imaginary parts are denoted as x and y.
  543. C++ offers a class complex which is of double precision; the real and
  544. imaginary parts are accessible via the functions real and imag. There is
  545. also a number of mathematical functions available for this class.
  546. Finally, the new Standard C++ library, included in Borland C++ 5, offers the
  547. classes complex<float>, complex<double>, and complex<long double>, equipped
  548. with basic functionality and the same range of mathematical functions
  549. offered by the class complex.
  550.  
  551. Most compilers (including Borland C++, unfortunately) implement these
  552. functions very inefficiently and inaccurately. (Just writing down the
  553. textbook formula for a complex function, like it is usually done, works
  554. fine only for a very limited range of arguments!)
  555.  
  556. Our aims are
  557. *   to make the use of complex numbers of all three data types
  558.     possible in C as well as in C++,
  559. *   to allow for the most efficient implementation of all complex operations,
  560.     using assembler code instead of C++ templates,
  561. *   and to introduce an easy, compact and consistent nomenclature.
  562.  
  563. To this end, the new complex math library CMATH was created and is shipped
  564. together with VectorLib. CMATH is described in greater detail in the file
  565. CMATH.TXT. If you use any of the non-vectorized functions contained in CMATH,
  566. you should include <newcplx.h> (for C++ modules) or <cmath.h> (for plain-C
  567. modules) before (!) any of the VectorLib include files.
  568.  
  569. VectorLib itself contains the necessary initialization functions of complex
  570. numbers and all vectorized forms of complex math functions. If you are using
  571. only these, you need not explicitly include CMATH. In this case, the
  572. following complex data types are defined in <VecLib.h>:
  573. typedef  struct { float     Re,  Im; }  fComplex;
  574. typedef  struct { double    Re,  Im; }  dComplex;
  575. typedef  struct { extended  Re,  Im; }  eComplex;
  576.  
  577. (the data type extended is used as a synonym for long double, see above.)
  578.  
  579. If, for example, a complex number z is declared as  "fComplex  z;", the real
  580. and imaginary parts of z are available as z.Re and z.Im, resp. Complex numbers
  581. are initialized either by setting the real and imaginary parts separately to
  582. the desired value, e.g.,
  583.     z.Re = 3.0;   z.Im = 5.7;
  584.  
  585. or, alternatively, the same initialization can be accomplished by the
  586. function fcplx:
  587.     z = fcplx( 3.0, 5.7 );
  588.  
  589. For double-precision complex numbers, use dcplx, for extended-precision
  590. complex numbers, use ecplx.
  591.  
  592. Pointers to arrays or vectors of complex numbers are declared using the data
  593. types cfVector, cdVector, and ceVector  described below.
  594.  
  595.  
  596.  
  597. 2.3 Vectors and Arrays:
  598. The Data Types  fVector,  dVector,  eVector,  cfVector,  cdVector,  ceVector,
  599.                 siVector, iVector,  liVector,  qiVector,
  600.                 usVector, uVector,  ulVector,  and  uiVector
  601. -----------------------------------------------------------------------------
  602.  
  603. We define, as usual, a "vector" as a one-dimensional array of data containing,
  604. at least, one element, with all elements being of the same data type. Using a
  605. more mathematical definition, a vector is a rank-one tensor. A two-dimensional
  606. array (i.e. a rank-two tensor) is denoted as a "matrix", and higher
  607. dimensions are always referred to as "tensors".
  608.  
  609. In contrast to other approaches, VectorLib does not allow zero-size vectors!
  610.  
  611. The basis of all VectorLib routines is formed by the various vector data
  612. types given below and declared in <VecLib.h>. In your programs, you may mix
  613. these vector types with the static arrays of classic C style.
  614. For example:
  615. float   a[100];           /* classic static array */
  616. fVector b=VF_vector(100); /* VectorLib vector */
  617. VF_equ1( a, 100 );      /* set the first 100 elements of a equal to 1.0   */
  618. VF_equC( b, 100, 3.7 ); /* set the first 100 elements of b equal to 3.7  */
  619.  
  620. In contrast to the fixed-size static arrays, the VectorLib types use dynamic
  621. memory allocation and allow for varying sizes. Because of this increased
  622. flexibility, we recommend that you predominantly use the latter.
  623. Here they are:
  624. typedef     float *            fVector;
  625. typedef     double *           dVector;
  626. typedef     long double *      eVector;
  627. typedef     fComplex *         cfVector;
  628. typedef     dComplex *         cdVector;
  629. typedef     eComplex *         ceVector;
  630. typedef     short *            siVector;
  631. typedef     int  *             iVector;
  632. typedef     long *             liVector;
  633. typedef     quad *             qiVector;
  634. typedef     unsigned short *   usVector;
  635. typedef     unsigned *         uVector;
  636. typedef     unsigned long *    ulVector;
  637. typedef     ui *               uiVector;
  638.  
  639. Thus, internally, a data type like fVector means "pointer to float", but
  640. you may think of a variable declared as fVector rather in terms of a
  641. "vector of floats". The data types ui, quad, fComplex, dComplex and eComplex
  642. themselves are described above.
  643.  
  644. Note: in connection with Windows programs, often the letter "l" or "L" is
  645. used to denote "long int" variables. In order to prevent confusion, however,
  646. the data type "long int" is signalled by "li" or "LI", and the data type
  647. "unsigned long" is signalled by "ul" or "UL".  Conflicts with prefixes for
  648. "long double" vectors are avoided by deriving these from the alias name
  649. "extended" and using "e", "ce", "E", and "CE", as described above and in the
  650. following.
  651.  
  652.  
  653.  
  654. 2.4 Real-number Functions:
  655.     The Prefixes VF_,  VD_,  and VE_
  656. ------------------------------------
  657.  
  658. The VectorLib package supports the three floating-point data types that are
  659. used by the coprocessors of the 80x87 family and the FPU units integrated
  660. into the 486DX and Pentium processors and their successors:  float,  double,
  661. and extended (i.e., long double).  BCD numbers are not supported.
  662.  
  663. Any of the algebraic and mathematical functions included in this library
  664. exists in one variant for each floating-point format. The data type of all
  665. floating-point vector elements, parameters, and of the return value is always
  666. the same within one function. The data type is signalled by the second letter
  667. of the prefix: VF_ denotes the variant of a function that uses exclusively
  668. the data type float, VD_ stands for the data type double, and VE_ for the
  669. data type extended, i.e., long double. (The first letter, "V", stands for
  670. "Vector function", of course.)  VF_ functions thus work on arrays declared as
  671. fVector, use parameters of the type float, and, if there is any floating-point
  672. return value, this will also be of the type float. There are no mixed-type
  673. functions (that would, e.g., work on vectors of type fVector, use parameters
  674. of type double and return a value of type long double).
  675.  
  676. One partial exception from this rule comes from the fact that, in Borland C++,
  677. floating-point return values are always stored as long doubles on the number
  678. stack; if you use the option "Fast floating point" (in the IDE in the menu
  679. "Options/Compiler/Advanced Code Generation",  or in the command-line compiler
  680. the option "-ff"), you may assign the return value of a function to a
  681. variable of another data type. For example, the product of all elements of a
  682. vector may easily overflow, and it is a good idea to define   eProd  as an
  683. extended (i.e., as a long double), before writing the line
  684.    eProd = VF_prod( X, size );  .
  685.  
  686. For the description of the functions in the Alphabetical Reference
  687. (chapter 8), generally only the VF_ version is described and its syntax
  688. explicitly given. The versions for the data types double and long double
  689. are exactly analogous to the VF_ variant. You have only to replace the
  690. prefix  "VF_" by  "VD_" (or  "VE_") and to use  "dVector" and "double"
  691. (or "eVector" and "extended", resp.) wherever you find "fVector" and "float"
  692. in the VF_ version.
  693.  
  694.  
  695.  
  696. 2.5 Complex-number Functions:
  697.     The Prefixes VCF_, VCD_, and VCE_
  698. --------------------------------------
  699.  
  700. Any prefix with its second letter being "C" denotes a function of complex
  701. numbers. By analogy with the nomenclature used for real-number functions, the
  702. prefix VCF_ signals the exclusive use of single-precision vectors, parameters
  703. and return values (fComplex, cfVector and float). Similarly, VCD_ is used for
  704. double-precision calculations, and VCE_ for extended precision. Wherever
  705. "fComplex", "cfVector", and "float" appear in the description of a function in
  706. the VCF_ version, the VCD_ and VCE_ versions are obtained by substituting with
  707. "dComplex",  "cdVector" and "double"  or "eComplex", "ceVector", and "extended"
  708. (or "long double"), resp.
  709.  
  710. Note: Return values of the data types fComplex, dComplex, and eComplex are
  711. not possible in Turbo Pascal. Therefore, the syntax of those functions
  712. returning a complex number is different in C/C++ and Turbo Pascal.
  713.  
  714. In contrast to the carelessness with which complex mathematical functions are
  715. often treated (see above), the complex functions of VectorLib are written
  716. such as to achieve full accuracy over the complete range of input/output
  717. values possible with the respective data type.
  718.  
  719. In order to perform non-vectorized complex operations with the same level
  720. of speed and reliability as the vectorized ones, use CMATH as a replacment
  721. of the complex class libraries. See the file CMATH.TXT for details.
  722.  
  723.  
  724.  
  725. 2.6 Functions of the Integer Data Types:
  726.     The Prefixes VI_, VSI_,  VLI_, VQI_, VU_, VUS_, VUL_, and VUI_
  727. ------------------------------------------------------------------
  728.  
  729. The nomenclature for the integer data types is designed in a similar way as
  730. for the floating-point data types: VI_ indicates the use of the data type
  731. int, VSI_ stands for short int, VLI_ for long int and VQI_ for quad
  732. integers, VU_ denotes operations with unsigned integers, VUS_ with unsigned
  733. short and VUL_ is the prefix for functions of unsigned long arguments. For
  734. operations on index-arrays, functions with the prefix VUI_ allow to perform
  735. calculations using arguments of the data type ui defined above. The VUI_
  736. versions are always defined as macros, and the compiler automatically
  737. substitutes either the VU_ or the VUL_ version, whichever is appropriate for
  738. the memory model actually used.
  739.  
  740. Don't be afraid of so many data types. It is one of the advantages of C
  741. language to have them, and it is one of the disadvantages, at the same time,
  742. that a programming style is supported which mixes all the data types until
  743. it is no longer clear "who is who".  In all normal cases, the VI_, VLI_,
  744. VU_, and VUI_ functions should be sufficient; but keep in mind that there
  745. are more available in case you need them.
  746.  
  747. If present, the vectorized integer functions are always described together
  748. with their floating-point analogues. To obtain, for example, the VI_
  749. version, vectors of type iVector have to be substituted for those of type
  750. fVector which are demanded by the VF_ version. In the same way, the other
  751. versions are obtained by changing "float" and "fVector" into the desired
  752. data type.
  753.  
  754. Like the function names themselves, also the include-files in which the
  755. functions are declared are named according to the data type they belong to.
  756. Thus, the declarations for the functions of the data type int are to be
  757. found in <VIstd.h> and <VImath.h>, those of the data type unsigned long in
  758. <VULstd.h> and <VULmath.h>, and so on.
  759.  
  760.  
  761.  
  762. 2.7 Common Functions of Several Data Types:  The Prefix V_
  763. ----------------------------------------------------------
  764.  
  765. Several functions exist that are either used independently of any data type
  766. or that are used to interconvert the data types. Functions like V_initPlot
  767. and V_free belong to the first case (you have to initialize the plotting
  768. routines regardless of the data type of the vectors you are going to plot,
  769. and the initialization is not specific for any data type).
  770. A function like V_ULtoD  belongs to the second case; here, a  ulVector
  771. (a vector whose elements are of the data type unsigned long) is transformed
  772. into a dVector (a vector whose elements are doubles).
  773. The type-independent functions are declared in <VecLib.h> and <Vgraph.h>.
  774. The data-type interconversion functions are declared in the include-files
  775. belonging to the destination type (i.e. the type into which the numbers are
  776. converted).
  777.  
  778.  
  779. ****************************************************************************
  780. *                                                                          *
  781. *******                      3. The Environment                      *******
  782. *                                                                          *
  783. ****************************************************************************
  784.  
  785. 3.1 The Different Library Versions:
  786.     Selecting Language, Memory Model, and Processor
  787. ---------------------------------------------------
  788.  
  789. The VectorLib routines may be used both in C and in C++ programs.
  790. Depending on your choice when ordering or downloading the Shareware version,
  791. you got one of the following three series of libraries:
  792.     VCF3W.LIB                            for Win32 (model FLAT of Windows95
  793.                                          and NT),
  794.     VCL3W.LIB + MCL3W.LIB + CMATHL3W.LIB for Windows3.x, model LARGE,
  795.     VCL3.LIB  + MCL3.LIB  + CMATHL3.LIB  for DOS Standard or DOS Overlay,
  796.                                          model LARGE.
  797.  
  798. The nomenclature of these libraries stems from the registered version which
  799. supports all memory models of DOS and Windows, each with its own set of
  800. libraries (for the three hardware configurations 486DX+, 386/387+, and 286+).
  801. The library name "VCL3W" means: [V]ectorLib for [C]/C++, memory model [L]arge,
  802. [3]86/387 processor or higher, for [W]indows programs. The names of the
  803. MatrixLib libraries begin with "MC..", the CMATH libraries with "CMATH..".
  804.  
  805. As has already been noted above, this Shareware version cannot be used on
  806. 286 machines and not on computers without coprocessor. In these cases, you
  807. would have to get, for example, the library VCL2.LIB of the registered
  808. version.
  809.  
  810.  
  811.  
  812. ****************************************************************************
  813. *                                                                          *
  814. *******           4. VectorLib Functions and Routines:               *******
  815. *******              A Short Overview                                *******
  816. *                                                                          *
  817. ****************************************************************************
  818.  
  819.  
  820. 4.1 Generation, Initialization and De-Allocation of Vectors
  821. -----------------------------------------------------------
  822.  
  823. With VectorLib, you may use static arrays (like, for example, float a[100];)
  824. as well as dynamically allocated ones (see chapter 2.3). We recommend,
  825. however, that you use the more flexible vector types defined by VectorLib,
  826. using dynamic allocation. This is described in the following sections.
  827. After a vector has been declared (e.g., as  fVector X; ), memory has to be
  828. allocated. When the vector is no longer needed, the memory it occupies has
  829. to be de-allocated again. For the allocation of memory, one specific function
  830. exists for each data type:  VF_vector,   VD_vector,  VI_vector,  and so on.
  831. If, together with the allocation, all elements shall be initialized with 0,
  832. VF_vector0,  VD_vector0,  VI_vector0,   etc. may be called.  To de-allocate
  833. memory, one and the same function is used for all data types:  V_free. In
  834. order to de-allocate several vectors with only one call, use V_nfree.
  835. V_freeAll frees all vectors at once.
  836.  
  837. Internally, the allocated vectors are written into a table to keep track
  838. of the allocated memory. If you try to free a vector that has never been
  839. or is no longer allocated, you get a warning message, and nothing is freed.
  840.  
  841. You might wonder why we add still more memory allocation functions to the
  842. already rich omnium gatherum of C and C++. The reason is that, for every
  843. environment and every memory model, the most appropriate memory management
  844. functions shall be selected automatically. This means that you, the user,
  845. need not deal yourself with the various methods, but can leave this task
  846. to VectorLib. Moreover, this makes your programs more easily portable.
  847. (Of course, the operator "new" offers similar benefits, but it is available
  848. only in C++. Since VectorLib shall be useable both in C and C++, it has
  849. to include its own functions for this purpose.)
  850.  
  851. The following functions are used to initialize or re-initialize vectors that
  852. have already been created:
  853. VF_equ0   sets all elements of a vector equal to 0;
  854. VF_equ1   sets them equal to 1;
  855. VF_equC   sets them equal to a constant.
  856. VF_equV   makes one vector a copy of another,
  857. VFx_equV  (the "expanded" version of the equality operation) relates each
  858.           element of a vector to the corresponding element of another
  859.           according to the formula  Yi = a * Xi + b.
  860.  
  861. VF_ramp   fills a vector with a "ramp" according to the formula  Xi = a*i + b.
  862. VF_random fills a vector with high-quality random numbers,
  863. VF_noise  with white noise, and
  864. VF_comb   with a "comb" function which, at equidistant points, equals a
  865.           constant C and is zero elsewhere.
  866.  
  867. VF_Hanning,  VF_Parzen, and VF_Welch are special functions creating so-called
  868. windows for use in spectral analysis (see VF_spectrum).
  869.  
  870. Complex vectors may be initialized by assigning the real and imaginary parts
  871. separately:  VF_ReImtoC,  VF_RetoC, and VF_ImtoC. Alternatively, they may be
  872. formed out of polar coordinates: VF_PolartoC.
  873.  
  874.  
  875.  
  876. 4.2 Index-oriented Manipulations
  877. --------------------------------
  878.  
  879. VF_rev       is used to reverse the ordering of the elements of a vector.
  880. VF_reflect   sets the upper half of a vector equal to the reversed lower half.
  881. VF_rotate    is used to rotate the ordering of the elements.
  882. VF_insert    and
  883. VF_delete    insert or delete an element of a vector.
  884.  
  885. VF_sort      is used for fast sorting of the elements into ascending or
  886.              descending order. If only an index-array, but not the elements
  887.              themselves are to be rearranged,
  888. VF_sortind   does the job.
  889. VF_subvector extracts a subvector from a (normally larger) vector, using a
  890.              constant sampling interval.
  891. VF_indpick   fills a vector with elements "picked" from another vector
  892.              according to their indices.
  893. VF_indput    is the complement of VF_indpick and distributes the elements of
  894.              one vector to the sites of another vector specified by their
  895.              indices.
  896.  
  897. Operations performed only on a sampled sub-set of elements of a vector are
  898. provided by the   VF_subvector_...  family, where the omission mark stands
  899. for a suffix denoting the desired operation.
  900.  
  901. VF_searchC   searches for the element of a vector that is closest to a
  902.              pre-set value (with a parameter "mode" deciding if the closest,
  903.              the closest larger-or-equal, or the closest smaller-or-equal
  904.              value is chosen).
  905. VF_searchV   does the same for a whole array of pre-set values.
  906.  
  907. Polynomial, rational, and cubic-spline interpolations are performed by
  908. VF_polyinterpol,  VF_ratinterpol, and VF_splineinterpol, resp.
  909.  
  910.  
  911.  
  912. 4.3 Data-Type Interconversions
  913. ------------------------------
  914.  
  915. The first thing that has to be said about the floating-point data-type
  916. interconversions is: do not use them too extensively. Decide which accuracy
  917. is appropriate for your application, and then use consistently either the
  918. VF_, or the VD_, or the VE_ version of the functions you need. Nevertheless,
  919. every data type can be converted into every other, in case it is necessary.
  920.  
  921. The functions used for the interconversion of the real-value floating-point
  922. data types are: V_FtoD,  V_DtoF,  V_FtoE,  V_EtoF,  V_DtoE,  and V_EtoD.
  923. Similarly, the following functions are offered for the complex floating-
  924. point data types: V_CFtoCD,  V_CDtoCF,  V_CFtoCE,  V_CEtoCF,  V_CDtoCE,  and
  925. V_CEtoCD.
  926.  
  927. Corresponding to the large number of integer data types, there is an even
  928. larger number of functions interconverting them. Switching between "normal",
  929. short, long and "quadruple" integers is performed by V_ItoLI,  V_ItoQI,
  930. V_ItoSI,  V_SItoI,  V_SItoLI,  V_SItoQI,  V_LItoSI,  V_LItoI,  V_LItoQI,
  931. V_QItoSI,  V_QItoI,  and V_QItoLI.
  932.  
  933. Similarly, the available types of unsigned numbers are interconverted by
  934. V_UtoUL,  V_UtoUS,  V_UtoUI,  V_UStoU,  V_UStoUL,  V_UStoUI,  V_ULtoUS,
  935. V_ULtoU,  V_ULtoUI, V_UItoU,  V_UItoUS,  and V_UItoUL.
  936.  
  937. Interconversions between signed and unsigned types can only be performed on
  938. the same level of accuracy, namely by the functions V_ItoU,  V_UtoI,  V_LItoUL,
  939. V_ULtoLI,  V_SItoUS,  and V_UStoSI.  That means that functions like V_UStoLI
  940. do  n o t  exist!
  941.  
  942. The conversion of integers into floating-point types is accomplished by
  943. V_ItoF,  V_ItoD,  V_ItoE,  V_SItoF,  V_SItoD,  V_SItoE,  V_LItoF,  V_LItoD,
  944. V_LItoE,  V_QItoF,  V_QItoD,  V_QItoE,  V_UtoF,  V_UtoD,  V_UtoE,  V_UStoF,
  945. V_UStoD,  V_UStoE,  V_ULtoF,  V_ULtoD,  V_ULtoE,  V_UItoF,  V_UItoD,   and
  946. V_UItoE. Again, do not be confused by the large number of these functions,
  947. but keep only in mind that for every interconversion there is one available.
  948.  
  949. The reverse process, the conversion of floating-point numbers into integers,
  950. is more complicated: although every integer (except for extremely large
  951. ones) has an exact representation in the floating-point types, this is not
  952. true the other way round: floating-point numbers may by definition contain
  953. fractional, i.e. "non-integer" parts. By choosing the appropriate rounding
  954. function, the user has to decide how to treat these fractional parts:
  955. Neglect them ("chop" or "trunc"), round to the nearest whole number ("round"),
  956. round to the next greater-or-equal integer ("ceil") or to the next smaller-or-
  957. equal integer ("floor"). These options are treated as mathematical functions
  958. and are described in chapter 4.6.1.
  959.  
  960.  
  961.  
  962. 4.4 More about Integer Arithmetics
  963. ----------------------------------
  964.  
  965. Although the rules of integer arithmetics are quite straightforward, it
  966. appears appropriate to recall that all integer operations are implicitly
  967. performed modulo 2**n, where n is the number of bits the numbers are
  968. represented with. This means that any result, falling outside the range of
  969. the respective data type, is made to fall inside the range by loosing the
  970. highest bits. The effect is the same as if as many times 2**n had been added
  971. to (or subtracted from) the "correct" result as necessary to reach the legal
  972. range.
  973. For example, in the data type short, the result of the multiplication 5 *
  974. 20000 is  -31072. The reason for this seemingly wrong negative result is
  975. that the "correct" result, 100000, falls outside the range of short numbers
  976. which is -32768 <= x <= +32767.  short integers are 16-bit numbers, so n = 16,
  977. and 2**n = 65536. In order to make the result fall into the specified range,
  978. the processor "subtracts" 2 * 65536 = 131072 from 100000, yielding -31072.
  979.  
  980. Note that overflowing intermediate results cannot be "cured" by any following
  981. operation. For example, (5 * 20000) / 4 is not (as one might hope) 25000,
  982. but rather -7768.
  983.  
  984. Note furthermore that the 64-bit data type quad does not employ this implicit
  985. modulo 2**n-arithmetics. Overflow conditions lead to undefined results.
  986.  
  987.  
  988.  
  989. 4.5 Basic Functions of Complex Vectors
  990. --------------------------------------
  991.  
  992. The following functions are available for the basic treatment of complex
  993. vectors.
  994. VF_ReImtoC      forming a complex vector out of its real and imaginary parts,
  995. VF_RetoC        overwriting the real part,
  996. VF_ImtoC        overwriting the imaginary part,
  997. VF_CtoReIm      extracting the real and imaginary parts,
  998. VF_CtoRe        extracting the real part,
  999. VF_CtoIm        extracting the imaginary part,
  1000. VF_PolartoC     forming a complex vector out of polar coordinates,
  1001. VF_CtoPolar     transforming a complex vector into polar coordinates,
  1002. VF_CtoAbs       calculating the absolute value (the magnitude of the pointer
  1003.                 in the complex plane),
  1004. VF_CtoArg       calculating the argument (the angle of the pointer in the
  1005.                 complex plane),  and
  1006. VF_CtoNorm      calculating the norm (which is defined here as the square of
  1007.                 the absolute value).
  1008.  
  1009.  
  1010.  
  1011. 4.6 Mathematical Functions
  1012. --------------------------
  1013.  
  1014. Lacking a more well-founded definition, we denote as "mathematical" all
  1015. those functions which calculate each single element of a vector from the
  1016. corresponding element of another vector by a more or less simple
  1017. mathematical formula:  Yi = f( Xi ).   Except for the "basic arithmetics"
  1018. functions, they are defined only for the floating-point data types. Most of
  1019. these mathematical functions are vectorized versions of ANSI C functions or
  1020. derived from them. Errors are handled by _matherr and _matherrl.  In
  1021. addition to this error handling "by element", the return values of the
  1022. VectorLib math functions show if all elements have been processed
  1023. successfully. If so, the return value is 0, otherwise it is any non-zero
  1024. int number.  (We do not yet use the newly introduced data type bool for
  1025. this return value, in order to make VectorLib compatible also with older
  1026. versions of Borland C.)
  1027.  
  1028.  
  1029. 4.6.1 Rounding
  1030. --------------
  1031.  
  1032. As noted in connection with data-type interconversions, the conversion of
  1033. floating-point numbers to integer data types may be accomplished by four
  1034. different ways: Fractional parts may be neglected (VF_chop, VF_trunc), or
  1035. the numbers may be rounded to the nearest integer (VF_round),  to the next
  1036. greater-or-equal integer (VF_ceil), or to the next smaller-or-equal integer
  1037. (VF_floor).
  1038.  
  1039. The result of the rounding operation thus specified may either be left in
  1040. the original floating-point format, e.g., in VF_round, or it may be converted
  1041. into one of the integer types, as in VF_roundtoI,  VD_ceiltoLI, VF_choptoSI,
  1042. or VE_floortoQI. As long as the input numbers are positive, they can also be
  1043. rounded to the unsigned integer types,  as in VF_floortoU, VF_ceiltoUS,
  1044. VD_choptoUL, or VE_trunctoUI.
  1045.  
  1046.  
  1047.  
  1048. 4.6.2 Comparisons
  1049. -----------------
  1050.  
  1051. Functions performing comparisons are generally named VF_cmp... (where
  1052. further letters and/or numbers specify the type of comparison desired).
  1053. Every element of a vector can be compared either to 0, or to a constant C,
  1054. or to the corresponding element of another vector. There are two
  1055. possibilities: either the comparison is performed with the three possible
  1056. answers "greater than", "equal to" or "less than". In this case, the results
  1057. are stored as floating-point numbers (0.0,  1.0,  or -1.0). Examples are
  1058. VF_cmp0,  VD_cmpC,  and VE_cmpV.
  1059.  
  1060. The other possibility is to test if one of the following conditions is
  1061. fulfilled: "greater than", "greater than or equal to", "equal to", "not
  1062. equal to", "less than", or "less than or equal to". Here, the answers will
  1063. be "TRUE" or "FALSE" (1.0 or 0.0). Examples are VF_cmp_eq0,  VD_cmp_gtC, and
  1064. VE_cmp_leV.
  1065.  
  1066. Alternatively, the indices of the elements for which the answer was "TRUE"
  1067. may be stored in an index-array, as in VF_cmp_neCind, VD_cmp_lt0ind,  and
  1068. VE_cmp_geVind.
  1069.  
  1070. To test if (at least) one element of a table is equal to a preset value, the
  1071. function VF_iselementC may be used. In order to test for each element of a
  1072. vector, if it has an identical entry in a table, VF_iselementV should be
  1073. used.
  1074.  
  1075.  
  1076.  
  1077. 4.6.3 Direct Bit-Manipulation
  1078. -----------------------------
  1079.  
  1080. For the integer data types, a number of bit-wise operations is available:
  1081. VI_shl and VI_shr shift the bits to the left or to the right, resp., which
  1082. is used for the fast multiplication and division by integer powers of 2.
  1083. The principal use of VI_and is the fast modulo division of positive or
  1084. unsigned numbers, while VI_or,  VI_xor, and VI_not  will find use only in
  1085. special applications.
  1086.  
  1087.  
  1088.  
  1089. 4.6.4 Basic Arithmetics
  1090. -----------------------
  1091.  
  1092. In the following list, only the VF_ function is explicitly named, but the
  1093. VD_ and VE_ functions exist as well; if it makes sense, the same is true for
  1094. the complex and for the integer-type versions:
  1095.  
  1096. VF_neg        Yi = - Xi;
  1097. VF_abs        Yi = │ Xi │;
  1098. VCF_conj      Yi.Re = Xi.Re; Yi.Im = -(Xi.Re).
  1099. VF_inv        Yi = 1.0 / Xi;
  1100. VF_equC       Xi = c;                VF_equV     Yi = Xi;
  1101. VF_addC       Yi = Xi + c;           VF_addV     Zi = Xi + Yi;
  1102. VF_subC       Yi = Xi - c;           VF_subV     Zi = Xi - Yi;
  1103. VF_subrC      Yi = c - Xi;           VF_subrV    Zi = Yi - Xi;
  1104. VF_mulC       Yi = Xi * c;           VF_mulV     Zi = Xi * Yi;
  1105. VF_divC       Yi = Xi / c;           VF_divV     Zi = Xi / Yi;
  1106. VF_divrC      Yi = c / Xi;           VF_divrV    Zi = Yi / Xi;
  1107. VF_modC       Yi = Xi mod c;         VF_modV     Zi = Xi mod Yi.
  1108.  
  1109. Besides these basic operations, several frequently-used combinations of
  1110. addition and division have been included, not to forget the Pythagoras
  1111. formula:
  1112.  
  1113. VF_hypC    Yi = Xi / (Xi + c);        VF_hypV    Zi =  Xi / (Xi + Yi);
  1114. VF_redC    Yi = (Xi * c) / (Xi + c);  VF_redV    Zi =  (Xi * Yi) / (Xi + Yi);
  1115. VF_visC    Yi = (Xi - c) / (Xi + c);  VF_visV    Zi =  (Xi - Yi) / (Xi + Yi);
  1116. VF_hypotC  Yi = sqrt( Xi² + c² );     VF_hypotV     Zi =   sqrt( Xi² + Yi²).
  1117.  
  1118. All functions in the right column of the above two sections also exist in an
  1119. expanded form (with the prefix VFx_...) in which the function is not
  1120. evaluated for Xi itself, but for the expression (a * Xi + b),  e.g.,
  1121. VFx_addV:   Zi  =  (a * Xi + b) + Yi.
  1122.  
  1123. The simple algebraic functions exist also in yet another special form,
  1124. with the result being scaled by some arbitraty factor. This scaled
  1125. form gets the prefix VFs_.
  1126. VFs_addV     Zi = C * (Xi + Yi);
  1127. VFs_subV     Zi = C * (Xi - Yi);
  1128. VFs_mulV     Zi = C * (Xi * Yi);
  1129. VFs_divV     Zi = C * (Xi / Yi);
  1130.  
  1131. VF_maxC     sets Yi equal to Xi or C, whichever is greater;
  1132. VF_minC     chooses the smaller of Xi and C;
  1133. VF_maxV     (and  VF_minV) set Zi equal to Xi or Yi, whichever is greater
  1134.             (or smaller, resp.).
  1135. VF_limit    limits the range of values, while
  1136. VF_flush0   sets all values to zero which are below a preset threshold.
  1137. VF_intfrac  splits the numbers into their integer and fractional parts;
  1138. VF_mantexp  splits the numbers into their mantissa and exponent parts.
  1139.  
  1140. In its geometrical interpretation, a vector is a pointer, with its elements
  1141. representing the coordinates of a point in n-dimensional space. There are a
  1142. few functions for geometrical vector arithmetics, namely
  1143. VF_scalprod,  which calculates the scalar product of two vectors,
  1144. VF_xprod,     which calculates the cross-product (or vector product) of two
  1145.               vectors, and
  1146. VF_Euclid,    calculating the Euclidean norm of a vector.
  1147.  
  1148.  
  1149.  
  1150. 4.6.5 Powers
  1151. ------------
  1152.  
  1153. VF_square,  VF_cubic, and VF_quartic, along with their expanded versions
  1154. VFx_square,  VFx_cubic,  and VFx_quartic, are used to calculate the second,
  1155. third and fourth power of the elements of the input vector. Arbitrary
  1156. integer powers are available by VF_ipow; fractional powers are calculated by
  1157. VF_pow. Polynomials are evaluated by VF_poly.
  1158.  
  1159. All these functions raise arbitrary numbers to specified powers, whereas the
  1160. following group of functions is used to raise specified numbers to arbitrary
  1161. powers: VF_pow10, VF_ipow10,  VF_pow2,  and VF_ipow2  raise 10 or 2, resp.,
  1162. to the (fractional or integer) powers specified in the input vector.
  1163. The exponential function, VF_exp, raises Euler's constant e to the powers
  1164. specified in the input vector. Finally, VF_expArbBase calculates the
  1165. exponential function of an arbitrary base.
  1166. The square-root, which corresponds to a power of 0.5,  is available with
  1167. VF_sqrt.
  1168.  
  1169. The corresponding functions for complex numbers are VCF_square,  VCF_cubic,
  1170. VCF_quartic,  VCF_ipow,  VCF_pow,  VCF_exp,  VCF_expArbBase, and VCF_sqrt.
  1171.  
  1172.  
  1173.  
  1174. 4.6.6 Exponentials and Hyperbolic Functions
  1175. -------------------------------------------
  1176.  
  1177. A variety of functions are derived from the exponential function VF_exp (which
  1178. itself has already been mentioned in the last section).
  1179. VF_expc   calculates the complementary exponential function Yi = 1 - exp[Xi].
  1180. VF_expmx2 calculates the exponential function of the negative square of the
  1181.           argument,  Yi = exp[ - Xi² ]. This is a bell-shaped function similar
  1182.           to the Gaussian distribution function which itself is available as
  1183. VF_Gauss.
  1184.  
  1185. The vectorized hyperbolic sine, cosine, tangent, cotangent, secant, and
  1186. cosecant functions are available as VF_sinh, VF_cosh, VF_tanh, VF_coth,
  1187. VF_sech, and VF_cosech. Because of its importance in physics, the squared
  1188. hyperbolic secant is also available as VF_sech2.
  1189.  
  1190. For complex numbers,  VCF_sinh,  VCF_cosh,  and VCF_tanh are available.
  1191.  
  1192.  
  1193.  
  1194. 4.6.7 Logarithms
  1195. ----------------
  1196.  
  1197.            The decadic logarithm (i.e., the logarithm to the basis 10) is
  1198.            available as
  1199. VF_log10,  the natural logarithm (i.e., to the basis e) is obtained by
  1200. VF_log,    and the binary logarithm (i.e., to the basis 2) is implemented as
  1201. VF_log2.   Similarly, for complex numbers,
  1202. VCF_log,  VCF_log10, and VCF_log2  (as always with their VCD_ and VCE_
  1203.            counterparts) are included.
  1204.  
  1205.  
  1206.  
  1207. 4.6.8 Trigonometric Functions
  1208. -----------------------------
  1209.  
  1210. The vectorized sine, cosine, tangent, cotangent, secant, and cosecant
  1211. functions are available as
  1212. VF_sin,       VF_cos,
  1213. VF_sincos     (sine and cosine at once!),
  1214. VF_tan,       VF_cot,
  1215. VF_sec,       and VF_cosec.
  1216.  
  1217. The squares of the trigonometric functions are available by
  1218. VF_sin2,      VF_cos2,
  1219. VF_sincos2    (again both the sin² and the cos² at once),
  1220. VF_tan2,      VF_cot2,
  1221. VF_sec2,      and VF_cosec2.
  1222.  
  1223. A very efficient way to calculate the trigonometric functions for arguments
  1224. representable as rational multiples of Pi is supplied by the trigonometric
  1225. functions with the suffix "rpi" (meaning "rational multiple of pi"):
  1226. VF_sinrpi, VF_cosrpi, VF_sincosrpi, VF_tanrpi, VF_cotrpi, VF_secrpi, and
  1227. VF_cosecrpi.
  1228. More specialized versions use tables to obtain frequently-used values;
  1229. these versions are denoted by the suffixes "rpi2" (multiples of Pi divided
  1230. by an integer power of 2) and "rpi3" (multiples of Pi over an integer
  1231. multiple of 3). Examples are VF_sinrpi2 and VF_tanrpi3.
  1232.  
  1233. The sinc function (quotient of the sine of an argument and the argument
  1234. itself) is available as the VF_sinc.
  1235.  
  1236. Vectorized inverse trigonometric functions are available as VF_asin,
  1237. VF_acos, VF_atan, and VF_atan2.
  1238.  
  1239. Complex trigonometric and inverse trigonometric functions are implemented as
  1240. VCF_sin,  VCF_cos,  VCF_tan,  VCF_asin,  VCF_acos,  and VCF_atan.
  1241.  
  1242.  
  1243.  
  1244. 4.7 Analysis
  1245. ------------
  1246.  
  1247. Global maxima and minima of real functions are detected by VF_max and
  1248. VF_min, resp. The same extrema, along with the index of their first
  1249. occurrence, are detected by VF_maxind and VF_minind, resp. To find the
  1250. maxima and minima in terms of absolute values, the functions VF_absmax and
  1251. VF_absmin are included along with the versions additionally yielding the
  1252. index, VF_absmaxind and VF_absminind. The "running" maximum and minimum
  1253. (where each element is set to the largest/smallest value occurring up to its
  1254. own index) are calculated by VF_runmax and VF_runmin, resp.
  1255.  
  1256. For complex numbers, the maximum real and imaginary parts may be found
  1257. separately by VCF_maxReIm, with the analogous function for the minima being
  1258. VCF_minReIm. For the separately-found maxima and minima of the real and
  1259. imaginary parts in absolute terms, use VCF_absmaxReIm and VCF_absminReIm.
  1260. Note that, for these four functions, the real and imaginary parts of
  1261. the result generally stem from different elements of the vector.
  1262.  
  1263. The largest absolute value (magnitude) occurring in a set of complex data is
  1264. found by VCF_absmax, the smallest one by VCF_absmin. To find the index of
  1265. the element with the largest/smallest magnitude along with that magnitude,
  1266. use VCF_absmaxind and VCF_absminind, resp.
  1267.  
  1268. The sum of all elements of a real or complex vector is available by VF_sum
  1269. and its higher-accuracy or complex analogues, the product by VF_prod and the
  1270. sum-of-squares by VF_ssq.  A summation over absolute values is performed
  1271. by VF_sumabs. VF_rms determines the r.m.s. of all elements of a vector.
  1272. Similarly to the "running" maximum, the running sum and product are available
  1273. by VF_runsum and VF_runprod, resp.
  1274.  
  1275. The derivative of a Y-array with respect to an X-array is calculated by
  1276. VF_derivV. If the intervals between the X-values are constant, the values
  1277. themselves are not needed for taking the derivative, but only the spacing is
  1278. required; VF_derivC should be employed in this case.
  1279. The integral of a Y-array over an X-array is calculated by the two functions
  1280. VF_integralV and VF_runintegralV, of which the first one determines only the
  1281. area under the curve defined by the input array, whereas the second one
  1282. calculates the point-by-point integral array. As for the derivative, also for
  1283. the integral the X-values themselves are not needed if they are equally-
  1284. spaced; in this case, VF_integralC and VF_runintegralC should be used.
  1285.  
  1286. VF_ismomoton   tests if an array is monotonously rising or falling.
  1287. VF_smooth      (which removes high-frequency noise),
  1288. VF_iselementC  (which tests, if a given value occurs within a vector), and
  1289. VF_searchC     (which searches an ordered table for the entry whose value
  1290.                comes closest to a preset value C) have to be mentioned as
  1291.                functions sometimes needed in connection with analysis.
  1292.  
  1293.  
  1294.  
  1295. 4.8 Signal Processing:
  1296.     Fourier Transforms and Related Topics
  1297. -----------------------------------------
  1298.  
  1299. The forward and the backward Fast Fourier Transform (FFT) are calculated by
  1300. VF_FFT or, for complex vectors, by VCF_FFT.
  1301.  
  1302. Based on FFT, convolution and deconvolution are available by
  1303. VF_convolve and VF_deconvolve.
  1304. Spectral filtering is achieved by VF_filter,
  1305. spectral analysis by VF_spectrum.
  1306. The autocorrelation function of a data array is obtained by VF_autocorr,
  1307. and the cross-correlation function of two arrays by VF_xcorr.
  1308.  
  1309. The FFT algorithm chosen for this PC implementation is a radix-2
  1310. Cooley-Tukey routine. Only for this radix-2 algorithm, the restricted
  1311. number of eight coprocessor registers still allows to hold all inter-
  1312. mediate results of the inner transform loop in coprocessor registers.
  1313. Although featuring savings in the number of multiplications, radix-4 and
  1314. radix-8 routines are rendered less efficient than the routine chosen by
  1315. the need of storing intermediate results in memory.
  1316.  
  1317. There are two different versions of all FFT-based functions. Depending
  1318. on the memory model, either of the two is automatically chosen. You
  1319. may, however, explicitly specify the one you wish to employ.
  1320. The first one uses the already-mentioned table of sine values (see
  1321. chapter 4.6.8. and the function VF_sinrpi2) as a look-up table for the
  1322. Fourier coefficients needed. This table needs up to 10 kBytes.
  1323. By default, this very fast variant is used in the memory models COMPACT
  1324. and LARGE. To explicitly specify it in the other memory models, please use
  1325. the prefixes VFl_, VDl_, VEl_ (with the letter "l" for the "larger" amount
  1326. of memory needed). 
  1327.  
  1328. The second variant, which is automatically chosen in all memory models
  1329. except for COMPACT and LARGE, employs trigonometric recursions to obtain the
  1330. sine and cosine values with still satisfactory speed, though this procedure
  1331. is not as fast as simply reading them from a table. You may explicitly
  1332. specifiy this variant by adding the letter "s" (for the "smaller" amount of
  1333. memory needed) in the function prefix. Examples are VFs_FFT, VDs_convolve,
  1334. VEs_spectrum.
  1335. If you decide to use this variant in order to economize memory in the models
  1336. COMPACT and LARGE, use the prefix VFs_ for all(!) routines employing FFT.
  1337. Otherwise, you will not only load the look-up table, but also a second FFT
  1338. routine into your already overcrowded memory.
  1339.  
  1340. Although it does not use Fourier transform methods, VF_smooth should be
  1341. remembered here as a crude form of frequency filtering which removes high-
  1342. frequency noise.
  1343.  
  1344.  
  1345.  
  1346. 4.9 Statistical Functions and Building Blocks
  1347. ---------------------------------------------
  1348.  
  1349. The mean (or average) of all the elements of a vector is obtained by
  1350. VF_mean; if different weights are to be attributed to the individual
  1351. elements, VF_meanwW ("mean with weights") may be used. The variance of a
  1352. distribution with respect to a preset constant value is calculated by
  1353. VF_varianceC (with weights by VF_varianceCwW), the variance with respect to
  1354. another array by VF_varianceV and VF_varianceVwW. To obtain the mean and the
  1355. variance of a distribution simultaneously, VF_meanvar and VF_meanvarwW are
  1356. used.
  1357. VF_meanabs calculates the mean of the absolute values.
  1358. If outlier points are to be excluded from the calculation of the mean,
  1359. VF_selected_mean allows to average only those vector elements which fall
  1360. into a specified range.
  1361.  
  1362. The median of a distribution is found by VF_median.
  1363.  
  1364. The linear correlation coefficient of two distributions is available by
  1365. VF_corrcoeff.
  1366.  
  1367. VF_sumdevC   sums up the deviations from a preset constant, sum( │Xi - C│ ).
  1368. VF_sumdevV   sums up the deviations from another vector, sum( │Xi - Yi│ ).
  1369. VF_avdevC    gives the "average deviation from a preset constant",
  1370.                      1/N * sum( │Xi - C│ ), and
  1371. VF_avdevV    gives the "average deviation from another vector",
  1372.                      1 / N * sum( │Xi - Yi│ ).
  1373. VF_ssqdevC   yields the "sum of the squares of the deviations from a preset
  1374.              constant",  sum( (Xi - C)² ),
  1375. VF_ssqdevV   the "sum of the squares of the deviations from another vector",
  1376.              sum( (Xi - Yi)² ).
  1377. VF_chi2      calculates the chi-square merit function, while
  1378. VF_chiabs    calculates a more "robust" merit function, summing up absolute
  1379.              instead of squared deviations.
  1380.  
  1381.  
  1382. A linear regression is performed on X-Y data by VF_linregress or, if the
  1383. individual data points are to be weighted, by VF_linregresswW.
  1384.  
  1385. Fitting of data sets to arbitrary functions is available in MatrixLib,
  1386. which contains the functions VF_polyfit, VF_linfit, VF_nonlinfit,
  1387. VF_multiLinfit, and VF_multiNonlinfit (see MATRIX.TXT).
  1388.  
  1389. VF_distribution bins data into a discrete one-dimensional distribution
  1390. function.
  1391.  
  1392. In connection with statistics, the functions VF_sum, VF_prod, VF_ssq,
  1393. VF_rms, and VF_iselementC should be remembered.
  1394.  
  1395.  
  1396.  
  1397. 4.10 Input and Output
  1398. ---------------------
  1399.  
  1400. There are several ways of printing the elements of a vector:
  1401. VF_cprint   prints them to the screen (or "console" - hence the "c" in the
  1402.             name) into the current text window, automatically detecting its
  1403.             height and width. After printing one page, the user is prompted
  1404.             to continue.
  1405. VF_print    is similar to VF_cprint in that the output is directed to the
  1406.             screen, but there is no automatic detection of the screen data;
  1407.             a default linewidth of 80 characters is assumed, and no division
  1408.             into pages is made.
  1409.             Both VF_print and VF_cprint should not be used within TurboVision.
  1410.             VF_cprint is not available under Windows. VF_print is available
  1411.             for DOS and EasyWin applications, but not for genuine (i.e., OWL)
  1412.             Windows programs.
  1413. VF_fprint   prints a vector to a stream. This may be a file, a printer, or
  1414.             again the screen. Nothing will prevent you from mis-using this
  1415.             function for printing to the screen in TurboVision or Windows,
  1416.             but you should not!
  1417.             VF_fprint is available in any environment (DOS, EasyWin and OWL).
  1418.  
  1419. VF_write   writes data in ASCII format in a stream
  1420. VF_read    reads a vector from an ASCII file.
  1421. VF_nwrite  writes n vectors of the same data type as the columns of a table
  1422.            into a stream.
  1423. VF_nread   reads the columns of a table into n vectors of the same type.
  1424.  
  1425. VF_setWriteFormat, VF_setWriteSeparate and VF_setNWriteSeparate allow
  1426. to modify the standard settings of VF_write and VF_nwrite.
  1427. For the whole-number variants of the ..read functions, a radix different
  1428. from the standard of 10 may be defined using V_setRadix.
  1429. V_setRadix does, however, not act on VQI_read.
  1430.  
  1431. VF_store and VF_recall are employed to store and retrieve data in binary
  1432. format (which is much faster and occupies fewer bytes of disk space than
  1433. ASCII format).
  1434.  
  1435.  
  1436.  
  1437. 4.11 Graphics
  1438. -------------
  1439.  
  1440. VectorLib includes a range of data-plotting routines.
  1441. Before any of them may be used, VectorLib graphics has to be initialized.
  1442. For DOS programs, this is done by V_initGraph. By calling V_initGraph, the
  1443. BGI functions (on which VectorLib's graphics functions rely) are
  1444. automatically initialized, too. Do not call initgraph after V_initGraph.
  1445. If you have already called initgraph, do not use V_initGraph, but V_initPlot
  1446. instead of it. At the end of the graphics session, the Borland C function
  1447. closegraph has to be used to leave the graphics mode and to release graphics
  1448. buffer memory.
  1449.  
  1450. For Windows programs, VectorLib graphics has to be initialized by V_initPlot.
  1451. No shut-down is needed at the end, since the Windows graphics functions
  1452. always remain accessible.
  1453.  
  1454. V_initPlot automatically reserves a part of the screen for plotting
  1455. operations. This part comprises about 2/3 of the screen on the right side.
  1456. Above, one line is left for a heading. Below, a few lines are left empty.
  1457. To change this default plotting region, call V_setPlotRegion after V_initPlot.
  1458.  
  1459. Only under Windows, all VectorLib plotting functions may directly be
  1460. used for printing on a printer. If this is desired, you have to call
  1461. V_initPrint instead of V_initPlot. By default, one whole page is reserved
  1462. for plotting. In order to change this, call V_setPlotRegion after V_initPrint.
  1463.  
  1464. VectorLib distinguishes between two sorts of plotting functions,
  1465. AutoPlot  and  DataPlot.
  1466.  
  1467. All AutoPlot functions (e.g., VF_xyAutoPlot) execute the following steps:
  1468. *   define a viewport within the plotting region (which is either the
  1469.     default region or the one defined by calling V_setPlotRegion)
  1470. *   clear the viewport
  1471. *   generate a Cartesian coordinate system with suitably scaled and labeled
  1472.     axes
  1473. *   plot the data according to the parameters passed to the function
  1474.  
  1475. All DataPlot functions (e.g. VE_yDataPlot) execute only the last of these
  1476. steps. They assume that a coordinate system already exists from a previous
  1477. call to one of the AutoPlot functions. The new plot is added to the existing
  1478. one. All settings of this coordinate system have to be valid. The viewport
  1479. must still be the active one and the scaling of the axes has to fit also for
  1480. the new data plot.
  1481.  
  1482. To add text and lables, a new viewport must be defined.
  1483. Use setviewport (DOS), SetViewportOrg (Windows with OWL 1.0), or
  1484. SetViewportOrgEx (Windows with OWL 2.0 or higher).
  1485.  
  1486. To switch back into text mode in DOS, use restorecrtmode.
  1487. After that, calling V_initPlot brings you back into graphics mode.
  1488.  
  1489. VF_xyAutoPlot   displays an automatically-scaled plot of an X-Y vector pair.
  1490. VF_yAutoPlot    plots a single Y-vector, using the index as X-axis.
  1491. VF_xy2AutoPlot  and
  1492. VF_y2AutoPlot   plot two X-Y pairs or two Y-vectors at once, doing the
  1493.                 necessary scaling so that both fit into the same coordinate
  1494.                 system.
  1495.                 To plot additional arrays into an already existing coordinate
  1496.                 system,
  1497. VF_xyDataPlot   and
  1498. VF_yDataPlot    should be used, as has already been mentioned.
  1499.  
  1500. Complex arrays are printed into the complex plane (the imaginary parts
  1501. versus the real parts), using
  1502. VCF_autoPlot,  VCF_2AutoPlot,  and  VCF_dataPlot.
  1503.  
  1504. The different plot styles, regarding symbols, lines, and colors, are
  1505. described in connection with VF_xyAutoPlot in the Function Reference
  1506. (file FUNCREF.TXT, chapter 8).
  1507.  
  1508. It is possible to draw more than one coordinate systems into a given
  1509. window on the screen. The position of each coordinate system must be
  1510. specified by the above-mentioned function V_setPlotRegion. "Hopping"
  1511. between the different coordinate systems and adding new DataPlots
  1512. after defining new viewports (e.g., for text output) is made possible
  1513. by the following functions:
  1514. V_continuePlot    go back to the viewport of the last plot and restore
  1515.                   its scalings
  1516. V_getCoordSystem  get a copy of the scalings and position of the current
  1517.                   coordinate system
  1518. V_setCoordSystem  restore the scalings and position of a coordinate system;
  1519.                   these must have been stored previously, using
  1520.                   V_getCoordSystem
  1521.  
  1522. DOS only:
  1523. When using multiple coordinate systems on the same screen, the default font
  1524. used for axis labeling might be too large, so that neighbouring labels
  1525. overlap each other. In these cases, use the BGI function settextstyle to
  1526. switch to another font befor calling a VectorLib AutoPlot function.
  1527.  
  1528.  
  1529. ****************************************************************************
  1530. *                                                                          *
  1531. *******                     5. Error Handling                        *******
  1532. *                                                                          *
  1533. *****************************************************************************
  1534.  
  1535. 5.1 General Remarks
  1536. -------------------
  1537.  
  1538. There are generally two types of error handling: by the hardware, or by the
  1539. software. In order to prevent uncontrolled program crash, it is highly
  1540. desirable that conditions, leading to hardware errors, be recognized before
  1541. the errors actually occur. All high-level computer languages support this
  1542. software error-handling to various degrees of perfection. Within the
  1543. tightly-defined functions and routines of this VectorLib package, often an
  1544. even more efficient error handling by the program itself is possible than
  1545. provided by the compilers for user-written code.
  1546.  
  1547. However, it should be noted that no absolute overflow protection is possible
  1548. for the long double versions. They do not have a "safety margin" left as in
  1549. the float and double versions, where internally all calculations are performed
  1550. in extended precision. Especially the VEx_ and VCEx_versions may fail if
  1551. constant parameters are very large, or if the X vector elements themselves are
  1552. already near the overflow limit. To be on the safe side, constant parameters
  1553. should not exceed about 1.E32 for float, 1.E150 for double, and 1.E2000 for
  1554. extended parameters.
  1555.  
  1556. In the "expanded" versions of all functions with extended accuracy (those
  1557. with the prefixes VEx_  and VCEx_;  for example VEx_exp), there is generally
  1558. no overflow protection for the calculation of A*Xi+B, but only for the core
  1559. of the function itself and for the final multiplication by C.
  1560.  
  1561. A series of identical errors occurring within one and the same VectorLib
  1562. function leads to one error message only. Subsequent identical messages are
  1563. suppressed.
  1564.  
  1565. There is a fundamental difference between floating-point and integer numbers
  1566. with respect to OVERFLOW and DOMAIN errors: for floating-point numbers,
  1567. these are always serious errors, whereas for integer numbers, by virtue of
  1568. the implicit modulo-2**n arithmetics, this is not necessarily the case. In the
  1569. following two paragraphs, details are given on the error handling of integer
  1570. and floating-point numbers, respectively.
  1571.  
  1572.  
  1573.  
  1574. 5.2 Integer Errors
  1575. ------------------
  1576.  
  1577. The only genuine integer errors are ZERODIVIDE errors (if a division by 0 is
  1578. attempted). Other integer errors are neglected due to the implicit definition
  1579. of integer operations to be done modulo the respective power of 2 (see
  1580. chapter 4.4). For those situations in which implicit modulo 2**n arithmetics
  1581. is not appropriate, VectorLib offers the possibility to trap these errors and
  1582. print an error message and/or abort the program. All functions where
  1583. INTEGER OVERFLOW (e.g., in VI_ramp, VI_mulV, etc.) or INTEGER DOMAIN errors
  1584. (e.g., in V_ItoU for negative X-values) may occur, exist in two versions:
  1585. the "normal" version employs modulo 2**n arithmetics and interchanges signed
  1586. and unsigned data types according to their bit pattern.
  1587.  
  1588. The other version also employs modulo 2**n arithmetics, but detects the
  1589. errors. To choose this version, the symbolic constant V_trapIntError must be
  1590. defined before(!) <VecLib.h> appears in the program header.
  1591.  
  1592. The action taken in case of INTEGER OVERFLOW errors is then defined by a call
  1593. to the function  V_setIntErrorHandling  with one of three possibilities as
  1594. the argument (defined as enum V_ihand in <VecLib.h>):
  1595.  
  1596. ierrNote      print an error message
  1597. ierrAbort     print an error message and exit the program
  1598. ierrIgnore    ignore the problem. With this last option, the error handling
  1599.               can be switched off intermediately.
  1600.  
  1601. Example:
  1602.     #define V_trapIntError 1
  1603.     #include <VIstd.h>
  1604.     #include <VImath.h>
  1605.     .....
  1606.     main()    /*   or WinMain(),  or OwlMain()   */
  1607.     {
  1608.         iVector  I1, I2;
  1609.         I1 = VI_vector( 1000 );  I2 = VI_vector( 1000 );
  1610.         V_setIntErrorHandling( ierrNote );
  1611.         VI_ramp( I1, 1000, 0, 50 );   /* an overflow will occur here! */
  1612.         V_setIntErrorHandling( ierrIgnore );
  1613.         VI_mulC( I2, I1, 1000, 5 );
  1614.             /* here, even a whole series of overflows will occur; they are
  1615.                all ignored. */
  1616.          ....
  1617.     }
  1618.  
  1619.  
  1620.  
  1621. 5.3 Floating-Point Errors
  1622. -------------------------
  1623.  
  1624. In order to understand the details of the floating-point error handling
  1625. outlined in the following sections, you may wish to refer to the description
  1626. of the functions _matherr and signal in the documentation of Borland C++
  1627. (prior to the version 4.0, instead of _matherr() the function matherr() -
  1628. without the leading underbar - was used, see below).  Keep in mind that
  1629. _matherr and _matherrl are the user-definable focal points for the handling
  1630. of all software-detected errors, whereas signal is used to install a handler
  1631. for hardware-detected errors (which should better be avoided in the first
  1632. place). Within the VectorLib functions, _matherr is used for the error
  1633. handling in the VF_, VCF_, VD_, and VCD_ versions, and _matherrl is used
  1634. in the VE_ and VCE_ versions.
  1635.  
  1636. Below, the possible types of errors are described. Here, we denote by
  1637. "HUGE_VAL" the largest number possible in the respective data type,
  1638. i.e. MAX_FLT, MAX_DBL, or MAX_LDBL. Similarly, "TINY_VAL" is the smallest
  1639. denormal number representable in the respective data type. This is not the
  1640. same as MIN_VAL, which is the smallest full-accuracy number of the respective
  1641. data type.
  1642.  
  1643. If the function in which an error occurs has one real-valued argument, only
  1644. the parameter e->x is defined in calling _matherr and e->y  is left undefined.
  1645. Only if there are two arguments (like in VF_atan2  or in VF_cotrpi),
  1646. both e->x  and e->y are needed to hold these arguments. For complex arguments,
  1647. the real part is stored in e->x  and the imaginary part in e->y.
  1648.  
  1649. For each function of the VectorLib package, the types of errors that are
  1650. detected and handled are described in the "Alphabetical Reference" (chapter 8).
  1651. All functions derived from ANSI C functions of the mathematical libraries
  1652. (those whose declarations are to be found in <math.h>)  contain a fully-
  1653. fledged mathematical error handling. In addition to the error handling
  1654. "by element", their return value shows if all elements have been processed
  1655. error-free (return value 0) or if an error occurred and was handled (return
  1656. value different from 0).
  1657.  
  1658. DOMAIN errors most often lead to the result NAN ("not-a-number"). Even if
  1659.     nothing happens within the function itself that detects a DOMAIN error,
  1660.     an uncontrolled program crash may result if subsequent operations are
  1661.     performed on the vector element set to NAN. We therefore recommend to
  1662.     modify _matherr and _matherrl in such a way that the program is aborted
  1663.     if a DOMAIN error occurs (for an example, see below; alternatively, the
  1664.     UNIX style may be adopted; see the file MATHERR.C supplied with the
  1665.     Borland C/C++ package). Changing the return value of _matherr is another
  1666.     possiblity, but the better way very clearly is to avoid any DOMAIN errors
  1667.     by performing appropriate checks before calling functions like VF_sqrt,
  1668.     VF_log, VF_atan2 etc.
  1669.        Note:  the pseudo-numbers INF and NAN are not allowed as input for any
  1670.        functions of the VectorLib library. They are not tested for; their
  1671.        presence will normally result in a hardware interrupt.
  1672.  
  1673. SING errors are treated like an extreme case of OVERFLOW (see below). In
  1674.     most cases, they arise from an implicit division by zero or from taking
  1675.     the logarithm of zero. The proposed result is never NAN, but always a
  1676.     "number", in most cases ±HUGE_VAL. Although it is recommended also in the
  1677.     case of SING errors to abort the program and take the necessary measures
  1678.     to avoid them, you may choose to continue program execution.
  1679.  
  1680. OVERFLOW errors are the most abundant form of floating-point errors. They
  1681.     are always handled by proposing +HUGE_VAL or -HUGE_VAL as the result.
  1682.     Within many user algorithms, OVERFLOW  errors may occur for intermediate
  1683.     results; if subsequent steps perform operations like taking the inverse,
  1684.     the final result may be acceptable despite the error. Therefore, we
  1685.     recommend to accept the return-value proposal and not to abort the
  1686.     program.
  1687.  
  1688. In principle, you may decide not to accept the return-value proposal of
  1689. _matherr, but to substitute another one. However, for several reasons
  1690. you are discouraged from doing that: the correct sign of the result is
  1691. set by the calling ("complaining") function in many cases only after
  1692. returning from _matherr;  the x-value passed to _matherr (which should
  1693. be inspected before the return value is modified) may either be X[i]
  1694. or (as in some of the expanded complex math functions of the VCEx_...
  1695. family) the intermediate result x' = Ax + B.  Note, furthermore, that
  1696. all x-values are passed to _matherr as double-precision floating-point
  1697. numbers, also in the case of integer input numbers (like in VF_tanrpi,
  1698. where P[i] and q are passed as x and y to _matherr).
  1699.  
  1700. TLOSS  ("total loss of precision") errors are handled by  _matherr only if a
  1701.     more serious error might occur in the respective function. For example,
  1702.     the sine function takes on values between -1 and +1 for all arguments.
  1703.     So, in case of an argument too big for the sine function to be evaluated
  1704.     with any accuracy, the result may nevertheless be "tacitly" set to 0.0
  1705.     and no call to _matherr is generated (whereas Borland C++ chooses NAN,
  1706.     "not a number", as the result, which is certainly even less correct than
  1707.     arbitrarily choosing 0.0).
  1708.     On the other hand, the cosecant, i.e. the inverse of the sine, is not
  1709.     defined for arguments of integer multiples of Pi. Therefore, a more
  1710.     serious error (in this case a SING or an OVERFLOW error) might be hidden
  1711.     under the TLOSS for very big arguments. This possibility is taken into
  1712.     account by calling _matherr, although the proposed result is again set
  1713.     to 0.0 (which is the mean of the two extremes +HUGE_VAL and -HUGE_VAL).
  1714.     Generally, the default result in the case of a TLOSS error is the mean of
  1715.     the results for arguments of +0.0 and -0.0.
  1716.  
  1717. UNDERFLOW errors are never detected; underflowing results are always
  1718.     "tacitly" set to denormal numbers or finally to 0.0 by the floating-point
  1719.     processor itself. Indeed, you may very rarely wish to do something else
  1720.     in this case.
  1721.  
  1722. As in all non-vectorized math functions of Borland C++, PLOSS ("partial loss
  1723. of precision") errors are never detected and precision problems simply
  1724. ignored.
  1725.  
  1726.  
  1727. 5.3.1 Differences between Borland C++ 4.0 and earlier versions
  1728. ------------------------------------------------------------------
  1729.  
  1730. Borland C++ uses the function _matherr in the way described above only
  1731. from version 4.0 on. Earlier versions employ the function matherr
  1732. (without the leading underbar in the function name). In order to be
  1733. usable both with the new and the old versions, VectorLib primarily
  1734. calls matherr as for the older versions. The include-file <VecLib.h>
  1735. provides a macro NEWMATHERR for the redirection of these calls to the
  1736. new _matherr(). This macro should appear somewhere in the module
  1737. containing the main() or WinMain() procedure, after the header:
  1738.     #include <VecLib.h>
  1739.     #include ...
  1740.     NEWMATHERR
  1741.       ......
  1742.     main()
  1743.     { ... }
  1744.  
  1745.  
  1746.  
  1747. 5.4 The Treatment of Denormal Numbers
  1748. -------------------------------------
  1749.  
  1750. "Denormal" are very small numbers between zero and the smallest full-
  1751. accuracy number available in the respective data type.  You may
  1752. understand the underlying principle from a simplified example:
  1753. 1.175494E-38 is the smallest "normal" float, with 7-digit accuracy.
  1754. What about 1/1024 of this value? This can only be represented as
  1755. 0.001145E-38, which is accurate to only four digits, since the first
  1756. three digits are needed to hold zeros. Thus, denormal numbers provide a
  1757. smooth transition between the smallest representable normal numbers and
  1758. zero.
  1759.  
  1760. In general, they may be treated just as ordinary numbers. In some instances,
  1761. however, like taking the inverse, overflow errors may occur. In these cases,
  1762. the somewhat academic distinction between SING and OVERFLOW errors is dropped
  1763. and a SING error signalled (as if it was a division by exactly 0).
  1764.  
  1765. On the other hand, for functions like the logarithms, very small input numbers
  1766. may give perfectly reasonable results, although the exact number 0.0 is an
  1767. illegal argument, leading to a SING error. Here, the possible loss of
  1768. precision is neglected and denormals are considered valid arguments.
  1769. (This treatment is quite different from that chosen for the math functions of
  1770. Borland C/C++, where denormal arguments lead to SING errors also in these
  1771. cases, which seems less appropriate to us.)
  1772.  
  1773.  
  1774.  
  1775. 5.5 Advanced Error Handling: Writing Messages into a File
  1776. ---------------------------------------------------------
  1777.  
  1778. ANSI C provides the user-definable function perror to print error messages.
  1779. However, several compilers, including Borland C++, do not use perror for
  1780. this purpose. This means that the way error messages are printed is not
  1781. controllable by the programmer. While this is fine in most instances, there
  1782. may be situations in which you might, for example, wish the error messages
  1783. not to be printed to the screen, but rather into a file, so that you could
  1784. check later what has gone wrong. If you use Borland C++ for Windows, an
  1785. additional motivation could come from the fact that, for any error, a
  1786. message box is displayed and program execution interrupted until you
  1787. acknowledge having taken notice of the error.
  1788.  
  1789. You might wish to circumvent this. To this end, VectorLib provides the
  1790. function  V_setErrorEventFile. This function needs as arguments the desired
  1791. name of your event file and a switch named ScreenAndFile which decides if the
  1792. error message is printed only into the file, or additionally to the screen
  1793. as well.
  1794.  
  1795. Note that this redirection of error messages is valid only for errors
  1796. occurring in VectorLib routines. If you wish to do so, however, there is a
  1797. way to extend the redirection also to the "non-VectorLib" functions:  you
  1798. may modify  _matherr and _matherrl such that the statement
  1799.     return 0;
  1800. (which signals an unresolved error)  is replaced by the sequence
  1801.     V_noteError( e->name, e->type ); return 1;
  1802. Thereby the task of printing the error message for unresolved errors is
  1803. passed to the VectorLib function V_noteError. Keep in mind that it is the
  1804. return value of _matherr which decides if an error message is printed by the
  1805. default error handler of Borland C/C++. Thus, after the call to V_noteError,
  1806. the printing of the default error messages is by-passed by returning "1".
  1807. (Also, do not forget that VectorLib uses your _matherr routine to determine
  1808. which errors you accept and which not!)
  1809.  
  1810. For example, your _matherr function (matherr - without the leading underbar
  1811. - for Borland C++ 3.0 and 3.1) might look like the following one:
  1812.  
  1813.     #include <math.h>
  1814.     int  _matherr( struct exception *e)
  1815.     {
  1816.         if( (e->type == UNDERFLOW) ││ (e->type == TLOSS) ) ;    /* ignore */
  1817.         else   /* all other errors deserve at least notice */
  1818.         {
  1819.               V_noteError( e->name, e->type );
  1820.               if (e->type == DOMAIN) exit(1); /* really fatal */
  1821.         }
  1822.         return 1;
  1823.     }
  1824.  
  1825. (Of course, if you decide to change _matherr, do not forget to change
  1826. _matherrl in the same way!).
  1827.  
  1828. The default printing of error messages on the screen alone is restored by
  1829. V_closeErrorEventFile.
  1830.  
  1831. A way to keep track also of those errors which do not lead to messages is
  1832. opened by the return values of mathematical VectorLib functions. Any of the
  1833. "silent" TLOSS along with the more serious DOMAIN, SING and OVERFLOW errors
  1834. will lead to a non-zero return value. You may wish to check for a clean
  1835. result after a group of functions, like in the following example:
  1836.  
  1837.    unsigned ErrFlag;
  1838.    ...
  1839.          /*   part Trig1  */
  1840.    ErrFlag=0;   /* reset the flag */
  1841.    ErrFlag |= VF_sin( Y1, X1, sz );
  1842.    ErrFlag |= VF_cos( Y2, X1, sz );
  1843.    ErrFlag |= VF_atan2( Z1, Y1, Y2, sz );
  1844.    if( ErrFlag ) printf( "Errors occurred in part Trig1 ! ");
  1845.    ...
  1846.  
  1847. As indicated in the example, it is better to use the   |=  operator instead
  1848. of  +=  (since,  in rare cases, all return values might add up to 65536,
  1849. which is stored as 0 due to an overflow of the integer variable). Even if
  1850. you chose addition of the individual return values, the number of occurred
  1851. errors would not be obtainable from the result; in case of an error, any
  1852. non-specified non-zero number is returned.
  1853.  
  1854.  
  1855.  
  1856. ****************************************************************************
  1857. *                                                                          *
  1858. *******                    6. Trouble-Shooting                       *******
  1859. *                                                                          *
  1860. ****************************************************************************
  1861.  
  1862.  
  1863. 6.1 General Problems
  1864. --------------------
  1865.  
  1866. In case of problems, please check first if VectorLib is correctly installed
  1867. (see chapter 1.4). If this is the case, carefully check the following points
  1868. whose violation would inevitably lead to failure.
  1869.  
  1870. *   The choice of the VectorLib library must match your selection of memory
  1871.     model, processor, and environment. You are not going to have much fun
  1872.     with the library VCL3.LIB under Windows3.x (where you need VCL3W.LIB).
  1873.  
  1874. *   You must not use vectors with a size of 0. All functions tacitly assume
  1875.     that the vectors have at least one element and do not waste your computer
  1876.     time testing for that.
  1877.  
  1878. *   You must not use vectors that are only declared, but have no allocated
  1879.     memory (see the description of VF_vector). If you did not switch off
  1880.     warnings, you may be warned also by the compiler not to do that
  1881.     ("possible use of xxx before definition").
  1882.  
  1883. *   Constant parameters should not exceed 1.E32 for floats, 1.E150 for
  1884.     doubles,  or 1.E2000 for long doubles. Normally, these ranges should
  1885.     suffice for any application...
  1886.  
  1887. *   16-bit only: Do not forget to write the line
  1888.         NEWMATHERR
  1889.     after the header into the module containing main(),  WinMain(),  or
  1890.     OwlMain(), in order to maintain compatibility both with older and later
  1891.     versions of Borland C++  (see chapter 5.3.1).
  1892.  
  1893. Although VectorLib has been tested very thoroughly, there is, of course,
  1894. always the possibility that a problem might have escaped our attention.
  1895. Should you feel you discovered a "bug" in VectorLib, please try to specify
  1896. the situation causing the problem as exactly as possible and let the author
  1897. know!
  1898.  
  1899.  
  1900.  
  1901. 6.2 Problems with Windows3.x?
  1902. ----------------------------
  1903.  
  1904. Programming for 16-bit Windows is much more involved than programming for
  1905. DOS. While DOS gives the programmer almost complete control over both the
  1906. main processor and the coprocessor, Windows demands much of this control for
  1907. itself. This introduces problems you should be aware of. They are not at all
  1908. specific to VectorLib. However, since they seem not to be very widely known,
  1909. here is a collection of some of them. Up to now, these problems have not
  1910. been observed with the memory model FLAT used with Win32 (Microsoft's 32-bit
  1911. extension of Windows 3.1), Windows NT and Windows95.
  1912.  
  1913. *   The background routines controlling intermediate results do not only work
  1914.     at the expense of your time, they may also at some point decide to load a
  1915.     NULL selector into the segment registers FS and GS. If you happen to use
  1916.     these registers (somehow, they were meant by Intel to be used), Windows'
  1917.     answer on your next operation will be the familiar "General Protection
  1918.     Fault (Error 13)". Therefore, the Windows versions of VectorLib do not
  1919.     use FS and GS at all.
  1920.  
  1921. *   If a multiplication or division happens to result in a so-called
  1922.     "denormal number" (see chapter 5.4), Windows at first accepts this
  1923.     result. The next time you use this denormal result, however, Windows
  1924.     decides that it had better been zero. Checking for zero by a comparison
  1925.     like
  1926.           if(x != 0.0)...
  1927.     yields the correct answer that x it is not zero, but, after (!) this
  1928.     check, Windows makes x exactly zero, if it is loaded onto the number
  1929.     stack. This leads to hard-to-find errors. If you inspect VectorLib
  1930.     routines with the debugger, you may at some points encounter strange,
  1931.     seemingly ineffecient code being used for comparisons. This is a fix for
  1932.     the described problem which costs time, but saves you from Windows-
  1933.     induced DIVIDE ERROR crashes.
  1934.  
  1935. *   Related to the last problem is another feature of Windows: after the
  1936.     comparison of two floats or two doubles, one of which is denormal, -NAN
  1937.     ("minus not-a-number")  may appear on the number stack. Some time later,
  1938.     this leads to a "Floating-point invalid" or a "Stack Overflow" error -
  1939.     another means of killing your application. If you encounter -NAN on the
  1940.     number stack when debugging your programs (with or without VectorLib
  1941.     used), you should find out which comparison(s) caused the problem and add
  1942.     the line
  1943.            asm  ffree ST(0);
  1944.     after this or these comparisons.
  1945.  
  1946.  
  1947.  
  1948. 6.3 Problems with the 16-bit Linker?
  1949. ------------------------------------
  1950.  
  1951. When working with large programs and libraries, older versions of TLINK
  1952. sometimes run into problems. You may get error messages like "Linker stack
  1953. overflow", "Out of memory", "Table limit exceeded", "Extended dictionaries
  1954. ignored", or "Unresolved external xxx referenced from module yyy".
  1955.  
  1956. Try to give the linker as much memory as possible by closing applications,
  1957. removing drivers etc. If that does not help, re-arrange your project list.
  1958. Curiously enough, that solves the problem sometimes.
  1959.  
  1960. In the case of "Unresolved external" linker errors, there is only one way
  1961. (if the error is not caused by wrong spelling). First you have to use TLIB
  1962. in order to get a listing of the respective library (see the description of
  1963. TLIB !). Screening the .LST file thus obtained with a text editor, you find
  1964. the module containing the symbol which the linker was unable to locate.
  1965. Using again TLIB, you have to extract this module from the library and add
  1966. the resulting .OBJ file to your project list.
  1967.  
  1968.  
  1969. 7. The include-files of VectorLib
  1970. ---------------------------------
  1971.  
  1972. The prototypes for the VectorLib routines are to be found in the include-
  1973. files described below. If you are using Borland's ObjectWindows Library
  1974. (i.e., if you write true Windows applications without relying on EasyWin),
  1975. the OWL include-files have to be included before (!) the VectorLib include-
  1976. files.
  1977.  
  1978. <VecLib.h> contains the basic definitions of the data types along with the
  1979. prototypes of the functions common to all data types (prefix V_) except for
  1980. the graphics initialization functions. The trigonometric tables (see chapter
  1981. 4.6.8) and the few non-vectorized math functions needed internally by
  1982. VectorLib  (see chapter 9), are made publically accessible and are declared
  1983. in <xmath.h>.
  1984.  
  1985. <newcplx.h> is the complex class library CMATH replacing Borland's
  1986. <complex.h> for C++ modules.
  1987. <cmath.h> and its "children" <cfmath.h>, <cdmath.h> and <cemath.h>
  1988. are the CMATH include files for plain-C modules.
  1989.  
  1990. <VIstd.h>, <VSIstd.h>, <VLIstd.h>, <VQIstd.h>, <VUstd.h>, <VUSstd.h>,
  1991. <VULstd.h>, <VUIstd.h>, <VFstd.h>,  <VDstd.h>,  <VEstd.h>,  <VCFstd.h>,
  1992. <VCDstd.h>,  and <VCEstd.h>
  1993. contain the prototypes of the functions used for the generation and
  1994. initialization of vectors, for index-oriented manipulations, data-type
  1995. interconversions, and I/O operations. For the floating-point data types,
  1996. they also contain the prototypes of routines for statistics, analysis,
  1997. geometrical vector arithmetics, and Fourier-Transform related functions. In
  1998. <VFstd.h>, the real-number functions for the data type float (prefix VF_)
  1999. are to be found, in <VDstd.h> those for the data type double, and so on.
  2000.  
  2001. The algebraic and mathematical functions are declared in the <V..math.h>
  2002. header files: <VImath.h>,  <VSImath.h>,  <VLImath.h>, <VQImath.h>,
  2003. <VUmath.h>,  <VUSmath.h>, <VULmath.h>,  <VUImath.h>, <VFmath.h>,
  2004. <VDmath.h>,  <VEmath.h>,   <VCFmath.h>,   <VCDmath.h>,  and  <VCEmath.h>.
  2005.  
  2006. <Vgraph.h> contains the prototypes of the graphics and plotting routines for
  2007. all data types.
  2008.  
  2009.  
  2010. *****************************************************************************
  2011.  
  2012.  
  2013. For detailed information on each single function of VectorLib, see the
  2014.  
  2015. S e c o n d  P a r t :  File  FUNCREF.TXT
  2016.  
  2017.  8.  Alphabetical Reference
  2018.  
  2019.  9.  Non-vectorized Functions
  2020.  
  2021. 10.  VectorLib Error Messages
  2022.  
  2023.  
  2024. *****************************************************************************
  2025.  
  2026. Copyright (C) Martin Sander 1996-1998
  2027.